none
Append table in pre written mail RRS feed

  • Question

  • Can somebody help me in appending a table at run time in mail on pressing send button Using VBA The text that pre written should also come if user has written any thing before appending table. (Note:-No copy paste of table from excel or word)
    Wednesday, October 24, 2018 10:03 AM

All replies

  • Hi sharjil,

    Actually, I'm not sure that what is your final demand. But as I understand, you would like to insert table in Outlook message with VBA? if so, you can refer to the following link:

    Sub mailtable()
    
    Dim ou As Object
    
    Dim oua As Object
    
    Set ou = CreateObject("outlook.application")
    
    Set oua = ou.CreateItem(0)
    
    With oua
    
        .To = "v-simol-msft@outlook.com"
    
        .Subject = "mailTable Test"
    
        .HTMLBody = "<table style='border: 1px solid black;'><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>"
    
       .Display
    
    End With
    
    End Sub

    Using the HTML table for this. Hopefully it helps you.

    Related link: Insert table in Outlook message with vba

    Regards,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, October 25, 2018 5:55 AM
    Moderator
  • Thanks Simon for replying. 

    My requirement is if user presses send button a userform should come and based on input from userform a table should be inserted between already written mail and signature.

    Ex

    Hi sharjil,

    How are you doing.

    I am fine.

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

    Here table should come.

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

    Sharjil(Signature part)<--------------

    Software developer

    Thursday, October 25, 2018 6:28 AM
  • Hi sharjil,

    Based on my experience, I think it should be done in the following steps:

    1. Monitor Outlook Send events

    2. Get Outlook input from userform values to email content, you could see the following link:

    Apply Outlook userform values to email template

    3. Add table to a specific location in body of email, like this

    .body = .body & "<br><table><table/>"  & signature

    There could be a lot of detail issue. However, this is just a way of thinking, hopefully it helps you.

    Regards,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, October 25, 2018 11:34 AM
    Moderator