Hello guys,
I use the following piece of code in order to create and send a reply message. The reply message has the Subject and Body updated.
PropertySet tmpitemv3 = new PropertySet(BasePropertySet.IdOnly);
tmpitemv3.Add(EmailMessageSchema.BccRecipients);
tmpitemv3.Add(EmailMessageSchema.Body);
tmpitemv3.RequestedBodyType = BodyType.Text;
tmpitemv3.Add(EmailMessageSchema.CcRecipients);
tmpitemv3.Add(EmailMessageSchema.DateTimeReceived);
tmpitemv3.Add(EmailMessageSchema.From);
tmpitemv3.Add(EmailMessageSchema.HasAttachments);
tmpitemv3.Add(EmailMessageSchema.Subject);
tmpitemv3.Add(EmailMessageSchema.ParentFolderId);
tmpitemv3.Add(EmailMessageSchema.ToRecipients);
EmailMessage tmpitem = EmailMessage.Bind(_ExchangeService, new ItemId(emailId), tmpitemv3);
ResponseMessage responseMessage = tmpitem.CreateReply(replyToAll);
responseMessage.Subject = MailSubject;
responseMessage.Body = new MessageBody(BodyType.Text, MailBody);
responseMessage.SendAndSaveCopy();
The problem appears when i try to insert a new Body in a specific email message. The message is a conversation with a lot of replies with many of them to be from different mobile clients(iPhone,WP,Adndroid).
If i insert the value "1" as string (MailBody = "1"/MailSubject="1") in the Body and Subject and the "SendAndSaveCopy()" runs, the reply message will arrive in Outlook but its body instead of "1" it contains the body of the original message. Also, the Sent:
value is not encoded correctly.
The red "Empty Body" was added to the picture by me to display that the body does not have a value.
No exception is returned.
It seems that there is something wrong with the body of the original message, an invalid char for example, but i could not locate it. Probably something fails on the server and returns the old body without the reply text.
1)EmailMessage.Bind()
EwsRequest
<Trace Tag="EwsRequest" Tid="12" Time="2012-10-11 13:25:21Z" Version="14.02.0051.000">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="GTB Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:GetItem>
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:BodyType>Text</t:BodyType>
<t:AdditionalProperties>
<t:FieldURI FieldURI="message:BccRecipients" />
<t:FieldURI FieldURI="message:CcRecipients" />
<t:FieldURI FieldURI="item:DateTimeReceived" />
<t:FieldURI FieldURI="message:From" />
<t:FieldURI FieldURI="item:HasAttachments" />
<t:FieldURI FieldURI="item:Importance" />
<t:FieldURI FieldURI="message:IsRead" />
<t:FieldURI FieldURI="item:Size" />
<t:FieldURI FieldURI="item:Subject" />
<t:FieldURI FieldURI="item:ParentFolderId" />
<t:FieldURI FieldURI="message:ToRecipients" />
<t:FieldURI FieldURI="item:Body" />
<t:ExtendedFieldURI PropertyTag="4224" PropertyType="Integer" />
<t:ExtendedFieldURI PropertyTag="4225" PropertyType="Integer" />
<t:ExtendedFieldURI PropertyTag="4226" PropertyType="SystemTime" />
</t:AdditionalProperties>
</m:ItemShape>
<m:ItemIds>
<t:ItemId Id="AAMkADMwMjUxYmFiLWFlMTUtNGEzMS04ODVmLTk3YTA1MmI4ZjQ0MQBGAAAAAADydAPT2CPrQ7mPmLhnFVs/BwAOnHJ31G54TJYzZEo7fdV2AAACIVDvAAC/XW/Glh3XS4Z3wJwSLHsvAAAD0UpOAAA=" />
</m:ItemIds>
</m:GetItem>
</soap:Body>
</soap:Envelope>
</Trace>
2) Response with the original email body in Text
EwsResponse
traceMessage:<Trace Tag="EwsResponse" Tid="12" Time="2012-10-11 13:25:23Z" Version="14.02.0051.000">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="1" MajorBuildNumber="421" MinorBuildNumber="2" Version="Exchange2010_SP1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId Id="AAMkADMwMjUxYmFiLWFlMTUtNGEzMS04ODVmLTk3YTA1MmI4ZjQ0MQBGAAAAAADydAPT2CPrQ7mPmLhnFVs/BwAOnHJ31G54TJYzZEo7fdV2AAACIVDvAAC/XW/Glh3XS4Z3wJwSLHsvAAAD0UpOAAA=" ChangeKey="CQAAABYAAAC/XW/Glh3XS4Z3wJwSLHsvAAAD7sTW" />
<t:ParentFolderId Id="AAMkADMwMjUxYmFiLWFlMTUtNGEzMS04ODVmLTk3YTA1MmI4ZjQ0MQAuAAAAAADydAPT2CPrQ7mPmLhnFVs/AQAOnHJ31G54TJYzZEo7fdV2AAACIVDvAAA=" ChangeKey="AQAAAA==" />
<t:Subject>Re: assistance required</t:Subject>
<t:Body BodyType="Text">Is this written in a guide anywhere, as I feel I wasted valuable time trying to get it sorted
It is not clear in the console, while save, save & close publish and app stays are large buttons
Update Cancel is so small and seems to indicate
To cancel any update.
Thanks for feedback
Keith
Sent from my iPhone
</t:Body>
<t:DateTimeReceived>2012-10-09T08:46:59Z</t:DateTimeReceived>
<t:Size>482158</t:Size>
<t:Importance>Normal</t:Importance>
<t:HasAttachments>false</t:HasAttachments>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertyTag="0x1080" PropertyType="Integer" />
<t:Value>261</t:Value>
</t:ExtendedProperty>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertyTag="0x1081" PropertyType="Integer" />
<t:Value>102</t:Value>
</t:ExtendedProperty>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertyTag="0x1082" PropertyType="SystemTime" />
<t:Value>2012-10-11T12:51:41Z</t:Value>
</t:ExtendedProperty>
<t:ToRecipients>
<t:Mailbox>
<t:Name>GZ</t:Name>
<t:EmailAddress></t:EmailAddress>
<t:RoutingType>SMTP</t:RoutingType>
</t:Mailbox>
</t:ToRecipients>
<t:CcRecipients>
<t:Mailbox>
<t:Name>NF</t:Name>
<t:RoutingType>SMTP</t:RoutingType>
</t:Mailbox>
<t:Mailbox>
<t:Name>NG</t:Name>
<t:RoutingType>SMTP</t:RoutingType>
</t:Mailbox>
</t:CcRecipients>
<t:From>
<t:Mailbox>
<t:Name>Keith Collyer</t:Name>
<t:RoutingType>SMTP</t:RoutingType>
</t:Mailbox>
</t:From>
<t:IsRead>true</t:IsRead>
</t:Message>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
</Trace>
3) Update Response Message, with Subject=1 and Body=1, and SendAndSaveCopy()
EwsRequest
<Trace Tag="EwsRequest" Tid="12" Time="2012-10-11 13:25:28Z" Version="14.02.0051.000">
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="GTB Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:CreateItem MessageDisposition="SendAndSaveCopy">
<m:SavedItemFolderId>
<t:DistinguishedFolderId Id="sentitems" />
</m:SavedItemFolderId>
<m:Items>
<t:ReplyToItem>
<t:Subject>1</t:Subject>
<t:Body BodyType="Text">1</t:Body>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>nfountas@globoplc.com</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
<t:CcRecipients />
<t:BccRecipients />
<t:ReferenceItemId Id="AAMkADMwMjUxYmFiLWFlMTUtNGEzMS04ODVmLTk3YTA1MmI4ZjQ0MQBGAAAAAADydAPT2CPrQ7mPmLhnFVs/BwAOnHJ31G54TJYzZEo7fdV2AAACIVDvAAC/XW/Glh3XS4Z3wJwSLHsvAAAD0UpOAAA=" ChangeKey="CQAAABYAAAC/XW/Glh3XS4Z3wJwSLHsvAAAD7sTW" />
</t:ReplyToItem>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>
</Trace>
ResponseOK, to each of the above functions.
At last when i get the reply message from the Inbox folder, the Body property is not "1".
EwsResponse
<Trace Tag="EwsResponse" Tid="12" Time="2012-10-11 13:48:17Z" Version="14.02.0051.000">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="1" MajorBuildNumber="421" MinorBuildNumber="2" Version="Exchange2010_SP1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:Message>
<t:ItemId Id="AAMkADMwMjUxYmFiLWFlMTUtNGEzMS04ODVmLTk3YTA1MmI4ZjQ0MQBGAAAAAADydAPT2CPrQ7mPmLhnFVs/BwAOnHJ31G54TJYzZEo7fdV2AAACIVDvAAC/XW/Glh3XS4Z3wJwSLHsvAAAD7kgxAAA=" ChangeKey="CQAAABYAAAC/XW/Glh3XS4Z3wJwSLHsvAAAD7sZv" />
<t:ParentFolderId Id="AAMkADMwMjUxYmFiLWFlMTUtNGEzMS04ODVmLTk3YTA1MmI4ZjQ0MQAuAAAAAADydAPT2CPrQ7mPmLhnFVs/AQAOnHJ31G54TJYzZEo7fdV2AAACIVDvAAA=" ChangeKey="AQAAAA==" />
<t:ItemClass>IPM.Note</t:ItemClass>
<t:Subject>1</t:Subject>
<t:Sensitivity>Normal</t:Sensitivity>
<t:Body BodyType="Text">
________________________________
From: Keith
Sent: ?????, 9 ????????? 2012 11:46:58 ??
To: GZ
Cc: NF; NG
Subject: Re: assistance required
Is this written in a guide anywhere, as I feel I wasted valuable time trying to get it sorted
It is not clear in the console, while save, save & close publish and app stays are large buttons
Update Cancel is so small and seems to indicate
To cancel any update.
Thanks for feedback
Keith
Sent from my iPhone
I am stuck. What can be going wrong?
I am willing to send the original email if i am asked.
Any help?
Thank you.