none
Outlook VBA to insert some banner text via a button RRS feed

  • Question

  • Hi,

    I need help to create a VBA for Outlook which will create a button or an option to click while drafting an email. This option when clicking will add a text banner to the emails at the top. I am not able to find the exact VBA code for what we want. Is there anyway one can provide a ready made VBA code to perform the same. User should have option to send email with banner or without banner. 


    Regards BM

    • Moved by Steve Fan Thursday, October 11, 2018 2:46 AM relocate
    Wednesday, October 10, 2018 2:15 PM

All replies

  • Hi,

    Welcome to the Microsoft Office for IT Professionals Outlook forum. This forum is for non-programming questions related to Microsoft Outlook. Since your request is related to VBA, I'll move it to the dedicated Outlook for Developers forum:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards,
    Steve Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, October 11, 2018 2:46 AM
  • Have you checked this post? Adding header text or a top-banner to all outgoing mail

    Also, you could refer to the following link:

    How to add image/banner as header or footer in outlook

    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 11, 2018 6:22 AM
    Moderator
  • I did the first link talks about stamping an image and not text. Also it gives a warning block for each email sent, we want some kind of a flag click which will stamp the banner on the email. I am not at all a VBA guy, i feel it is simple work but am failing to get that work as well. My requirement is simple as i mentioned above. 

    Regards BM

    Thursday, October 11, 2018 8:36 PM
  • Can somebody provide me the VBA code which i can test please?

    Regards BM

    Thursday, October 11, 2018 9:10 PM
  • Hi there,

    Sorry for late response. It seems that there is no a good solution to do this. Maybe we can format the text to HTML style e.g. Bold, Size .etc. Please refer to the following code:

    Sub SharePerformance()
    
    Dim OutApp As Object
    Dim OutMail As Object
    Dim rng As Range
    
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.createitem(0)
    '& "<a href=""\\server\folder"">\\server\folder</a>" &
    msg1 = "Team,<br><br><b><DL>" & Range("b5").Value & "</b><br><ul><b><u>" & Range("b6").Value & "</b></u>"
    msg1 = msg1 & "<DT><a HREF=C:\USER\Desktop\File1.xlsb>"
    msg1 = msg1 & Range("b7").Value & "</a><br>"
    msg1 = msg1 & "<b><u>" & Range("b9").Value & "</b></u></DL><br><br>"
    
    
    msg1 = msg1 & "<p><img src=file://" & "C:\temp\Chart1.png" & "></p>" & "<br>"
    
    On Error Resume Next
    ' Change the mail address and subject in the macro before you run it.
    
    With OutMail
        .To = Range("B1").Value
        .cc = ""
        .BCC = ""
        .Subject = Range("B3").Value
        .HTMLBody = msg1
        '.Attachments.Add ActiveWorkbook.FullName
        '.Attachments.Add ("C:\temp\Chart1.png")
        '.Attachments.Add ("C:\temp\Chart2.png")
        .display
    End With
    SendKeys "^{ENTER}"
    On Error GoTo 0
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    
    End Sub
    

    You can run it directly in Excel and update the text style as you needs.

    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.

    Tuesday, October 16, 2018 4:22 PM
    Moderator