none
[EWS2013][EWS][SOAP][WINDOWS]Change the :From field for email messages using EWS soap request. RRS feed

  • Question

  • Hi,

    Some users of our owa application need to have the from field of their Message changed to match a specific domain. I've written this soap request to change the from field :

    <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <soap:Body> <UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"> <ItemChanges> <t:ItemChange>

    <t:ItemId Id="AAA.." ChangeKey="CQA..." /> <t:Updates> <t:SetItemField> <t:FieldURI FieldURI="message:From"/> <t:Message> <t:From> <t:MailBox> <t:EmailAddress>testaddress@test.com</t:EmailAddress> </t:MailBox> </t:From> </t:Message> </t:SetItemField> </t:Updates> </t:ItemChange> </ItemChanges> </UpdateItem> </soap:Body>

    I'm using EWSEditor and the response sent back is pretty generic  500 error. I've assigned the user "send as" permission in exchange AD. And this operation can be carried out from the UI.
      


    Milton Cody


    • Edited by Milton BC Wednesday, September 16, 2015 9:37 PM update title
    Wednesday, September 16, 2015 9:28 PM

Answers

  • Your request is missing a few things like the RequestServerVersion and your also missing the closing envelope tag (I still can't make your request work with those so there is probably some other syntax errors). The following work request works okay for me

      <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="Exchange2013_SP1" />
        </soap:Header>
        <soap:Body>
          <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
            <m:ItemChanges>
              <t:ItemChange>
    	<t:ItemId Id="AAMkADczNDE=" ChangeKey="CQAAABAu" />
                <t:Updates>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="message:From" />
                    <t:Message>
                      <t:From>
                        <t:Mailbox>
                          <t:EmailAddress>room@domain.com</t:EmailAddress>
                        </t:Mailbox>
                      </t:From>
                    </t:Message>
                  </t:SetItemField>
                </t:Updates>
              </t:ItemChange>
            </m:ItemChanges>
          </m:UpdateItem>
        </soap:Body>
      </soap:Envelope>
    
    Cheers
    Glen
    • Marked as answer by Milton BC Thursday, September 17, 2015 3:36 PM
    Thursday, September 17, 2015 3:46 AM

All replies

  • Your request is missing a few things like the RequestServerVersion and your also missing the closing envelope tag (I still can't make your request work with those so there is probably some other syntax errors). The following work request works okay for me

      <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="Exchange2013_SP1" />
        </soap:Header>
        <soap:Body>
          <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
            <m:ItemChanges>
              <t:ItemChange>
    	<t:ItemId Id="AAMkADczNDE=" ChangeKey="CQAAABAu" />
                <t:Updates>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="message:From" />
                    <t:Message>
                      <t:From>
                        <t:Mailbox>
                          <t:EmailAddress>room@domain.com</t:EmailAddress>
                        </t:Mailbox>
                      </t:From>
                    </t:Message>
                  </t:SetItemField>
                </t:Updates>
              </t:ItemChange>
            </m:ItemChanges>
          </m:UpdateItem>
        </soap:Body>
      </soap:Envelope>
    
    Cheers
    Glen
    • Marked as answer by Milton BC Thursday, September 17, 2015 3:36 PM
    Thursday, September 17, 2015 3:46 AM
  • Thank you resolved the issue.

    Cheers,

    Milton C.


    Milton Cody

    Thursday, September 17, 2015 3:15 PM