Forum Discussion

Carl_Stephens's avatar
Carl_Stephens
Copper Contributor
Sep 24, 2020

A VBA code to open an email and paste information from tab.

Hello All,

I am looking for a code that will simply open an email and take the information below and paste it into the email. The mail server will be open already so I believe that it should not be that complicated considering a simple email address hyper link already opens an email with the email address in the To: field. Thank you for your time and appreciate it.

 

 

1 Reply

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    Carl_Stephens 

     

    Here is a little solution
    that it is not that easy, I think everyone can understand. The fact that it often looks simple comes from how well the desired description is described and thus the solution is also optimally adapted to the specific use.

    You would have to adjust the values, columns / rows as you would like.
    ------------------------------------------------
    SUB AREA_MAIL()

    Dim OutApp As Object, Mail As Object, i
    Dim message

    'then set the desired table area
    Range ("B1: D20"). Select
    Selection.Copy


    'Open the mail
    Set OutApp = CreateObject ("Outlook.Application")
    Set Message = OutApp.CreateItem (0)
    With message
    .Subject = "Subject text"
    .To = "Email@dresse.de"
    .Display
    End With
    Set OutApp = Nothing
    Set message = Nothing

    'Wait briefly so that the mail has time to open
    Application.Wait (Now + TimeValue ("0:00:05"))

    'Then paste the clipboard
    Application.SendKeys ("% bi") 'in the EDIT menu (Alt-B) select the e-insert
    'Application.SendKeys ("^ v")' Ctrl-V instruction is the 2nd option instead of Alt-B + I

    End Sub

    ---------------------------------

     

    *Just hope it's not about Excel Online.

     

    I would be happy to know if I could help.

     

    Nikolino

    I know I don't know anything (Socrates)

     

    * Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.

Resources