我希望在电子邮件中添加唯一的故障单ID,以便我可以看到哪个故障单属于该电子邮件。现在的想法是使用电子邮件边界。这怎么样?我很困惑这应该如何工作,甚至可以工作......现在我正在使用EWS发送这样的电子邮件:
EmailMessage email = new EmailMessage(service);
email.Subject = "Test from c#";
email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed Api");
email.Send();
如何为此代码添加电子邮件边界?我试过这样的事情:
ExtendedPropertyDefinition ticketId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "boundary := ticket-123", MapiPropertyType.String);
email.SetExtendedProperty(ticketId, "ID-12345678");
但这不起作用。提前谢谢!
答案 0 :(得分:1)
=
字符。正确的代码应如下所示:
ExtendedPropertyDefinition ticketId = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.InternetHeaders, "ticket-id", MapiPropertyType.String);
email.SetExtendedProperty(ticketId, "ID-12345678");
检查获取故障单ID的代码应如下所示:
string ticketId = null;
InternetMessageHeader ticketHeader =
message.InternetMessageHeaders.Find("ticket-id");
if (ticketHeader != null)
ticketId = ticketHeader.Value;
if (!string.IsNullOrEmpty(ticketId)) {
// TODO: Do something with the ticket ID
}