• Build email within Excel (Excel/Outlook 2003)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Build email within Excel (Excel/Outlook 2003)

    Author
    Topic
    #446446

    Hi All,

    Here’s what I’m trying to do.

    The user clicks a button on Sheet A. Some code runs that:

    • creates a new email
    • adds a bunch of recipients
    • adds a subject line
    • adds Sheet B as an attachment (in a separate .xls file)
    • inserts an area from Sheet C (a named range) into the body of the email
    • inserts the user’s outlook signature at the bottom of the body of the email
    • adds voting buttons (“Approve;Reject”)
    • sends the email
      [/list]I know how to do some of that… I’m specifically looking for help with the vba for building the body of the email and adding the voting buttons.

      Any help would be very much appreciated! cheers

    Viewing 0 reply threads
    Author
    Replies
    • #1085446

      I assume that you’re using Automation to control Outlook from within Excel.
      The MailItem object in Outlook VBA has a Body property that you can use to specify the (unformatted) body text. For example:

      Dim objMail As Outlook.MailItem
      Set objMail = …
      objMail.Body = “First paragraph” & vbCrLf & vbCrLf & “Second paragraph” & vbCrLf & “Third Paragraph”

      If you want to specify formatting in an HTML format e-mail, you can use the HTMLBody property. This allows the use of HTML tags such as and .

      You can specify voting buttons like this:

      objMail.VotingOptions = “Yes;No;Maybe”

      • #1085448

        You’re right Hans. I am using Automation.

        Why does it always seem so simple when you see the solution. I had found the VotingOptions property for the MailItem object but there were no examples anywhere of the statements setting the values. I thought it might have been a True/False thing instead of what I was really looking for. MSDN had “expression.votingoptions” and that was it. I suppose I should have played around more before asking the question.

        Thank you Hans! As always, you are the best! smile

    Viewing 0 reply threads
    Reply To: Build email within Excel (Excel/Outlook 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: