(视频)使用Word邮件合并功能批量发送带附件的邮件

  使用Word邮件合并功能批量发送带附件的邮件,可以非常方便的省去我们很多工作,不再为了一个个的写邮件,当然,如果只是几封邮件就没什么。如果有几百上千封不一样的邮件需要发送时怎么办?  一起来看看下面的方法吧。

VBA代码执行代码前,需要在VBA编辑器中添加对Outlook的引用。操作步骤:在VBA编辑器的“工具”菜单中,选择“引用”,并勾选类似于“Microsoft Outlook ##.0 Object Library”的引用,其中“##”是Outlook的版本号(2007是12.0,2010是14.0,2013是15.0)。Sub emailmergewithattachments()Dim Source As Document, Maillist As Document, TempDoc As DocumentDim Datarange As RangeDim i As Long, j As LongDim bStarted As BooleanDim oOutlookApp As Outlook.ApplicationDim oItem As Outlook.MailItemDim mysubject As String, message As String, title As StringSet Source = ActiveDocument’ Check if Outlook is running. If it is not, start OutlookOn Error Resume NextSet oOutlookApp = GetObject(, “Outlook.Application”)If Err <> 0 Then Set oOutlookApp = CreateObject(“Outlook.Application”) bStarted = TrueEnd If’ Open the catalog mailmerge documentWith Dialogs(wdDialogFileOpen) .ShowEnd WithSet Maillist = ActiveDocument’ Show an input box asking the user for the subject to be inserted into the email messagesmessage = “Enter the subject to be used for each email message.” ‘ Set prompt.title = ” Email Subject Input” ‘ Set title.’ Display message, titlemysubject = InputBox(message, title)’ Iterate through the Sections of the Source document and the rows of the catalog mailmerge document,’ extracting the information to be included in each email.For j = 1 To Source.Sections.Count – 1 Set oItem = oOutlookApp.CreateItem(olMailItem) With oItem .Subject = mysubject .Body = Source.Sections(j).Range.Text Set Datarange = Maillist.Tables(1).Cell(j, 1).Range Datarange.End = Datarange.End – 1 .To = Datarange For i = 2 To Maillist.Tables(1).Columns.Count Set Datarange = Maillist.Tables(1).Cell(j, i).Range Datarange.End = Datarange.End – 1 .Attachments.Add Trim(Datarange.Text), olByValue, 1 Next i .Send End With Set oItem = NothingNext jMaillist.Close wdDoNotSaveChanges’ Close Outlook if it was started by this macro.If bStarted Then oOutlookApp.QuitEnd IfMsgBox Source.Sections.Count – 1 & ” messages have been sent.”‘Clean upSet oOutlookApp = NothingEnd Sub使用Word邮件合并功能批量发送带附件的邮件(视频教程):上好网提示:因网络的原因,可能部分网友显示视频较慢,大家可刷新网页或耐心等待一会!
只有在前进中不断学会选择,学会体会,学会欣赏。

(视频)使用Word邮件合并功能批量发送带附件的邮件

相关文章:

你感兴趣的文章:

标签云: