【问题标题】:VB.NET - How to use an OFT or a DOCX as a template when sending an email (Exchange Web Service)VB.NET - 如何在发送电子邮件时使用 OFT 或 DOCX 作为模板(Exchange Web 服务)
【发布时间】:2015-07-19 15:29:23
【问题描述】:

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

这是我现在发送电子邮件的方式(工作):

    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%)替换为用户的实际名称。

谢谢, 加布里埃尔

【问题讨论】:

    标签: vb.net email templates exchangewebservices


    【解决方案1】:

    EWS 无法自动提供 Word 或 OFT 模板。您需要自己在代码中打开文件并从中生成正文。

    【讨论】:

    • 谢谢,这就是我最终做的。将 Word 文档加载为 html,然后将其作为正文粘贴。
    猜你喜欢
    • 1970-01-01
    • 2015-08-10
    • 2011-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    • 2011-12-03
    相关资源
    最近更新 更多