需要将电子邮件草稿另存为Outlook模板.oft格式

时间:2019-09-16 09:51:03

标签: 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 _
                & 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草稿另存为(* .oft)格式的Outlook模板的代码吗?

1 个答案:

答案 0 :(得分:1)

要将电子邮件作为模板保存到硬盘驱动器,可以使用Outlook .Save功能:

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

希望这会有所帮助。