jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
567 stars 302 forks source link

Setting Custom X-Headers when creating new message #531

Open l0ckm4 opened 5 years ago

l0ckm4 commented 5 years ago

Version (e.g. 1.0, dev-master): 1.0 PHP version: 5.4 Microsoft Exchange version: Exchange 2010 Description of problem: Need to set custom X-Headers

Is there any way to set custom x-headers to emails created using the 1.0 library?

avinash403 commented 4 years ago

Even I am struggling to find any documentation on this.

jameswillhoite commented 4 years ago

I know this is old, but I was able to successfully add a custom X-Header to my Message. And I was searching for a solution myself.

You must add a ExtendedPropertyType to the MessageType->ExtendedProperty[]

Example $Message = new MessageType(); / Add all Message Requirements /

//Add a Extended Property $EP = new ExtendedPropertyType(); $EP->ExtendedFieldURI = new PathToExtendedFieldType(); $EP->ExtendedFieldURI->DistinguishedPropertySetId = "InternetHeaders"; $EP->ExtendedFieldURI->PropertyName = "X-Dwc-Test"; //The custom X-Header $EP->ExtendedFieldURI->PropertyType = MapiPropertyTypeType::STRING; $EP->Value = 'String';

//Add the X-Header $Message->ExtendedProperty[] = $EP;

// Send the Message

I'm using it to know what department to send a list of emails to when/if the message bounces back from a un-monitored mailbox. I have to parse through the body of the Bounce message for it, but it is there.

l0ckm4 commented 4 years ago

I know this is old, but I was able to successfully add a custom X-Header to my Message. And I was searching for a solution myself.

You must add a ExtendedPropertyType to the MessageType->ExtendedProperty[]

Example $Message = new MessageType(); / Add all Message Requirements /

//Add a Extended Property $EP = new ExtendedPropertyType(); $EP->ExtendedFieldURI = new PathToExtendedFieldType(); $EP->ExtendedFieldURI->DistinguishedPropertySetId = "InternetHeaders"; $EP->ExtendedFieldURI->PropertyName = "X-Dwc-Test"; //The custom X-Header $EP->ExtendedFieldURI->PropertyType = MapiPropertyTypeType::STRING; $EP->Value = 'String';

//Add the X-Header $Message->ExtendedProperty[] = $EP;

// Send the Message

I'm using it to know what department to send a list of emails to when/if the message bounces back from a un-monitored mailbox. I have to parse through the body of the Bounce message for it, but it is there.

Stunning - thank you :-)

heberFigueroa commented 1 year ago

it didnt work for me. Did it work for anyone?