1

I have a user who sends eMails to a large "To" list, Sometimes over 20 addresses. With this large a "To" list, the received mail sometimes ends up on the recipient's SPAM folder. Obviously, we'd like to avoid this.

My idea is to have the user create an original eMail and then run a Macro. The Macro would loop through all the eMail addresses in an Excel worksheet and then copy the original message and send it to each recipient individually.

I'm unsure as to how to copy a MailItem from the original to a new MailItem. The Excel looping works fine.

Here's my abbreviated macro:

Option Explicit
Sub Send_emails()
'.
'.
Set objDoc = objInspector.WordEditor
Set objWrdApp = objDoc.Application
Set objSelection = objWrdApp.Selection
'Loop through the Rows in the worksheet.  Start at row 2 to ignore header
For lngCurrSheetRow = 2 To lngLastSheetRow
    strEmailAddress = objWorksheet.Cells(lngCurrSheetRow, 1).Value
    'Set objNewMail so that the new message is created and can be referenced.
    Set objNewMail = Application.CreateItem(0)
    With objNewMail
        .Body = objSelection
        .To = strEmailAddress
    End With
Next lngCurrSheetRow
'.
'.
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user3138025
  • 795
  • 4
  • 17
  • 46

1 Answers1

1

To copy mailitem.body Example would be

Option Explicit
Sub Send_emails()

        Dim olMsg As Outlook.MailItem
        Set olMsg = ActiveExplorer.Selection.Item(1)

        Dim objNewMail As Outlook.MailItem
        Set objNewMail = Application.CreateItem(0)

        With objNewMail
            .Body = olMsg.Body
            .Display
        End With
End Sub

For HTML Body simply do HTMLBody = olMsg.HTMLBody

0m3r
  • 12,286
  • 15
  • 35
  • 71
  • Hi 0m3r. Thanks. That worked. I had to change the SET olMsg to:SET olMsg = objInspector.CurrentItem That worked fine. However this doesn't copy rich text attributes (Bolded text, Different font size, etc.). I'm expecting to use WordMail as the editor. I have a statement to check for that earlier on in the macro (If objInspector.IsWordMail <> True Then.....) Thanks for answering this Copy question, but how can I get it to copy RICH TEXT? I should have specified that originally. – user3138025 Jan 14 '19 at 13:22
  • Update: I used RTFBody instead of Body (.RTFBody = olMsg.RTFBody). That's better. It preserves the Bold, Underscore and Hyperlinks nicely. But it doesn't handle a font size change (say from 11 to font size 24) or to include different font families (Arial, Times New Roman, etc.). – user3138025 Jan 14 '19 at 14:17
  • 1
    Hi user3138025. HTMLBody on both sides of the equation works perfectly. That statement within the With / End With series now reads: .HTMLBody = olMsg.HTMLBody Many thanks for your help. – user3138025 Jan 14 '19 at 16:55