简体   繁体   中英

How to add email boundary as extended property to DefaultExtendedPropertySet.InternetHeaders property set

I'm looking to add an unique ticket id to an email message, so that I can see what ticket belongs to that email. Now the idea was to use an email boundary. How would this work? I'm confused on how this should work, or even could work... Right now I'm using EWS to send email messages like this:

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();

How would I add an email boundary to this code? I tried something like this:

ExtendedPropertyDefinition ticketId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "boundary := ticket-123", MapiPropertyType.String);
email.SetExtendedProperty(ticketId, "ID-12345678");

But that doesn't work. Thanks in advance!

  1. You can't specify the = character in the header.
  2. You shouldn't include spaces in the header.
  3. Boundaries aren't in the header.
  4. You shouldn't use a boundary for that.

The correct code should look like this:

ExtendedPropertyDefinition ticketId = new ExtendedPropertyDefinition(
    DefaultExtendedPropertySet.InternetHeaders, "ticket-id", MapiPropertyType.String);
email.SetExtendedProperty(ticketId, "ID-12345678");

The code to check get the ticket ID should look like this:

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM