php-ews icon indicating copy to clipboard operation
php-ews copied to clipboard

Setting Custom X-Headers when creating new message

Open l0ckm4 opened this issue 7 years ago • 4 comments

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?

l0ckm4 avatar Nov 12 '18 15:11 l0ckm4

Even I am struggling to find any documentation on this.

avinash403 avatar Jul 22 '19 06:07 avinash403

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.

jameswillhoite avatar Apr 30 '20 17:04 jameswillhoite

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 :-)

l0ckm4 avatar May 26 '20 09:05 l0ckm4

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

heberFigueroa avatar May 08 '23 05:05 heberFigueroa