VB.NET - 发送电子邮件时如何使用 OFT 或 DOCX 作为模板(Exchange Web 服务)

VB.NET - How to use an OFT or a DOCX as a template when sending an email (Exchange Web Service)

我想通过使用 OFT(Outlook 模板)或 word 文档作为模板使用 ExchangeWeb 服务发送电子邮件。

这是我目前发送电子邮件的方式(有效):

    Public Sub SendEmailFrom3611(ByVal body As String, _
                                ByVal recipient As List(Of String), _
                                ByVal subject As String)

    Dim exch As ExchangeService = New ExchangeService(ExchangeVersion.Exchange2013)
    Const email3611 As String = "3611@domain.com"
    Const serviceNowUsr As String = "username"
    Const serviceNowPsw As String = "password"

    exch.AutodiscoverUrl(email3611)
    exch.Credentials = New WebCredentials(serviceNowUsr, serviceNowPsw)

    Dim email As New EmailMessage(exch)

    email.From = email3611
    email.ToRecipients.Add(email3611)

    For Each s As String In recipient
        email.ToRecipients.Add(s)
    Next s

    email.Subject = subject
    email.Body = body
    email.Body.BodyType = BodyType.HTML

    email.SendAndSaveCopy()

End Sub

发邮件可以用word文档做模板吗?在发送电子邮件之前,我会查看 word 文档并将一些变量(如 %FULLNAME%)替换为用户的实际名称。

谢谢, 加布里埃尔

EWS 没有任何自动提供 Word 或 OFT 模板的能力。您需要自己在代码中打开文件并从中生成正文。