![]() ' Should we display the message before sending?Ī note: Recipients, CC's and BCC's are expecting arrays of values, which may also only be a single value. ' Resolve each Recipient's name -this may not be necessary if you have fully qualified addresses. body = body 'this can also be HTML, which is great if you want to improve the look of your email, but you must change the format to match ' Set the Subject, Body, and Importance of the message. ' Add the BCC recipient(s) to the message. ' Add the CC recipient(s) to the message. ' Add the To recipient(s) to the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) Set objOutlook = CreateObject("Outlook.Application") Set objOutlook = GetObject(, "Outlook.Application") Here's my take on the email code for outlook (be sure to setup references->outlook object model, as I've used early biding) Sub SendMessage(recipients As Variant, subject As String, body As String, Optional ccRecips As Variant, Optional bccRecips As Variant, Optional DisplayMsg As Boolean, Optional AttachmentPath As Variant)ĭim objOutlookAttach As Outlook.Attachment MsgBox - 1 & " messages have been sent."įirstly, I'd separate out your email code, and the code for iterating your spreadsheet. ' Close Outlook if it was started by this macro. Attachments.Add Trim(Datarange.Text), olByValue, 1 Set Datarange = Maillist.Tables(1).Cell(j, i).Range Set Datarange = Maillist.Tables(1).Cell(j, 3).Rangeįor i = 2 To Maillist.Tables(1).Columns.Count ![]() Set Datarange = Maillist.Tables(1).Cell(j, 2).Range Set Datarange = Maillist.Tables(1).Cell(j, 1).Range Set oItem = oOutlookApp.CreateItem(olMailItem) ' extracting the information to be included in each email. ' Iterate through the Sections of the Source document and the rows of the catalog mailmerge document, Title = " Email Subject Input" ' Set title. Message = "Enter the subject to be used for each email message." ' Set prompt. ' Show an input box asking the user for the subject to be inserted into the email messages ![]() Set oOutlookApp = CreateObject("Outlook.Application") Set oOutlookApp = GetObject(, "Outlook.Application") Will throw error if this column does not exist.ĭim Source As Document, Maillist As Document, TempDoc As Documentĭim mysubject As String, message As String, title As String SaveSent = True 'Saves a copy of the messages into the senders "sent" boxĭisplayMsg = False 'Pulls up a copy of all messages to be sent - WARNING, do not use on long lists!ĪttachBCC = False 'Adds third column data into the BCC field. Also the body of the message does not show up.Īny pointers? Sub emailmergewithattachments()ĭim saveSent As Boolean, displayMsg As Boolean, attachBCC As Boolean It allowed me to cc, however, it only goes through with the first row of emails and none of the rest. I also read an article that shows how to send attachments to multiple recipients and modified it to make the cc work. I tried adding, and as well as merging two cells in excel with the addresses and got errors. I would also like each email to be include a CC that shows the same email to multiple recipients.Įxample: the same email to John Doe can be automatically cc'd to his manager. In other words, I not only need to personalize the emails to different email addresses. ![]() I am trying to add the cc function to a mail merge.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |