Excel 如何将电子邮件草稿保存为Outlook Template.oft格式?
我想将Outlook模板格式*.oft的电子邮件草稿保存在文件夹F:\Template\winword.2003中Excel 如何将电子邮件草稿保存为Outlook Template.oft格式?,excel,vba,outlook,Excel,Vba,Outlook,我想将Outlook模板格式*.oft的电子邮件草稿保存在文件夹F:\Template\winword.2003中 Sub SendMultipleEmails() Dim Mail_Object, OutApp As Object With OutApp .Subject = "My Acc Holding Holding") .Body = "Hello" & vbNewLine _ & vbN
Sub SendMultipleEmails()
Dim Mail_Object, OutApp As Object
With OutApp
.Subject = "My Acc Holding Holding")
.Body = "Hello" & vbNewLine _
& vbNewLine _
& "Please find the attached Acc Holding"
.Display
bc = ws.Range("F" & i + 1).Value
For j = first To i
bc = bc & ";" & ws.Range("F" & j).Value
Next
.BCC = bc
first = i + 2
.Display
.Close olSave
first = i + 2
End With
End If
Next
End Sub
要将电子邮件作为模板保存到硬盘,可以使用Outlook。保存功能:
oMail.SaveAs sPath & sName, olTemplate
其中sPath是您的路径,sName是您的文件名
在您的代码中应该是这样的:
Sub SendMultipleEmails()
Dim OutMail, OutApp As Object
Dim sPath As String, sName As String
sPath = "F:\Template\winword.2003\"
sName = "myTemplate.oft"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0) 'olMailItem
With OutMail
.Subject = "My Acc Holding Holding"
.Body = "Hello" & vbNewLine _
& vbNewLine _
& "Please find the attached Acc Holding"
bc = ws.Range("F" & i + 1).Value
For j = first To i
bc = bc & ";" & ws.Range("F" & j).Value
Next
.BCC = bc
first = i + 2
.Display
.SaveAs sPath & sName, olTemplate
.Close olSave
first = i + 2
End With
End Sub
希望这能有所帮助。首先,在代码末尾有“如果”而没有“如果”的“结束”和“下一步”而没有“For”循环。抱歉。。。它不是完整的代码。当你问问题时,代码应该足够完整,可以运行/测试。请参阅概念。获取运行时错误、应用程序定义错误或对象定义错误是,因为它缺少对象初始化。现在试试ofc,因为它不完整,我不能保证您的代码的其余部分。