![]() 'IMPORTANT: This assumes your email addresses in the table are separated with commas! ' 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 With Dialogs(wdDialogFileOpen) 'Hey, I'm not sure what this does, but I'm leaving it there. Sub DocumentSuperMailSenderMagicHopefully()ĭim Source As Document, Maillist As Document, TempDoc As Documentĭim mysubject As String, message As String, title As Stringĭim datarange As Range 'word range I'm guessing. This creates an array of addresses, which you can then iterate over and add to the recipient, CC or BCC. On writing this, I think you'll see the main trick for editing your own however - the key was splitting the text in the CC cell, by the delimiter you are using. ![]() I believe it should be very close though. ![]() I've built the below email, but I havn't spent a lot of time on it (or tested it, as it's quite specific to your tables). Now that we've built a nice generic way of sending emails (which is handily re-usable) we can think about the logic of the thing we've got sending emails. This means we can probably send it a raw range, or we can load that range into an array, and send it that. ' 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 Firstly, I'd separate out your email code, and the code for iterating your spreadsheet. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |