Office365 API 根据发件人电子邮件地址附加电子邮件签名

Office365 API append email signatures based on senders email address

我们正在考虑使用 Office365 API 来发送电子邮件。我们考虑使用 Office365 的原因之一是能够自动应用签名。因此,如果我们为特定用户发送自动电子邮件,我们是否能够指定我们希望将签名附加到该电子邮件?

我们是否需要使用与我们一起发送的用户的用户凭据,或者是否有可用的管理员角色允许使用来选择/自动应用正确的电子邮件签名?

谢谢,

AFAIK,当使用 O365 API 向特定用户发送电子邮件时,您不能 choose/apply 不同的签名。作为解决方法,使用 outlook mail rest api ,您可以创建一封电子邮件,在发送给特定用户时将电子邮件签名插入到电子邮件正文的末尾。您可以为电子邮件消息使用 HTML 正文,例如:

       // Create the email message text body.
       string htmlBodyTxt = @"<html><head></head><body><p>This is the email message body before a signature is added.</p>
                            </body></html>";

       // Identify the signature insertion point at the end of the HTML body.
       int signatureInsertPnt = htmlBodyTxt.IndexOf("</body>");

       // Create the email signature.
       string signature = "<p>Dallas Durkin<br/>Senior Planner<br/>Adventure Works Cycles</p>" +
                          "<p>4567 Main St.<br/>La Habra Heights, CA 90631</p><p>(323) 555-0100</p>";

       // Insert the signature into the HTML body.
       string newBody = htmlBodyTxt.Insert(signatureInsertPnt, signature);