locked
Exchange EWS IsReadReceiptRequested notification address RRS feed

  • Question

  • Hi there,

    I'm using EWS with Exchange 2010 SP1 Rollup 5.

    Easy to use from code, but I ran into a problem. There was a migration from Exhange 2003 and the application used WebDav, witch has the possibility to set the return recipient address.

    There is a layer to wrap all the mailing funcionlity and used it many way.

    Here is the code sample:

    using EWS = Microsoft.Exchange.WebServices.Data;

    // create the service object

     

          EWS.ExchangeService service = new EWS.ExchangeService(EWS.ExchangeVersion.Exchange2010_SP1);

          service.UseDefaultCredentials = true;

          service.Url = new Uri(/*get it from configuration*/);

    // if there was a from parameter we impersonate

          if (!string.IsNullOrEmpty(smtpAdress))

          {

            service.ImpersonatedUserId = new EWS.ImpersonatedUserId(EWS.ConnectingIdType.SmtpAddress, smtpAdress);

          }

     

     

    // create the message

     

            EWS.EmailMessage msg = new EWS.EmailMessage(service);

    // set the base properties such as body, subject, to, cc, bcc etc.

     

            if (isNeedConfirmation)

            {

              msg.IsReadReceiptRequested = true;

              //BUGBUG: ConfirmationAddress mail address

            }

     

            if (IsNeedReturnReceipt)

            {

              msg.IsDeliveryReceiptRequested = true;

              //BUGBUG: ReturnReceiptAddress ->  mail address

            }

     

    So the question is how can I set the email address who should get the delivery and read notification

    Thanks,

    Péter

     


    Monday, November 14, 2011 2:56 PM

All replies

  • Similar to what you would have being doing in WebDAV you set the ReplyTo address by modifying the following two Extended properties

    PidTagReplyRecipientEntries http://msdn.microsoft.com/en-us/library/cc815710.aspx

    and

    PidTagReplyRecipientNames http://msdn.microsoft.com/en-us/library/cc815850.aspx

    You should be able to reuse whatever WebDAV code you had for generating the value for PidTagReplyRecipientEntries then define and set them using something like

                ExtendedPropertyDefinition PidTagReplyRecipientEntries = new ExtendedPropertyDefinition(0x004F, MapiPropertyType.Binary);
                EmailMessage.SetExtendedProperty(PidTagReplyRecipientEntries,Value)
    

    Cheers
    Glen

     

     

    Tuesday, November 15, 2011 4:46 AM
  • Hi,

     

    I'm really new in Exchange and manually set up a web request.

    I'm not the original developer of the application.

    The original WebDav code manually put the whole request and set this attributes: Return-Receipt-to: <ReturnReceiptAddress> , disposition-notification-to: <ConfirmationAddress>

    I tried to use the code above like this:

          msg.IsReadReceiptRequested = true;

          msg.IsDeliveryReceiptRequested = true;

     

          UTF8Encoding encoding = new UTF8Encoding();

          byte[] value = encoding.GetBytes(<email address>);

          EWS.ExtendedPropertyDefinition PidTagReplyRecipientEntries = new EWS.ExtendedPropertyDefinition(0x004F, EWS.MapiPropertyType.Binary);

          msg.SetExtendedProperty(PidTagReplyRecipientEntries, value);

    I tried to substitue the <email address> with a simple email address and the WebDav code "Return-Receipt-to: <simple email address>"

    Both try resulted "An internal server error occurred. The operation failed." error with no inner exception.

    What did I wrong? Is there need any special privileges on the Exchange server?

     

    Thans,

    Péter

    Tuesday, November 15, 2011 8:33 AM
  • Try this it seems to work okay Those other props are from the Reply to if you where trying to set multiple replyto etc

                EmailMessage em = new EmailMessage(service);
                em.Subject = "test";
                em.Body = new MessageBody("Test 123");
                ExtendedPropertyDefinition PR_ReadReceiptAddrType_W = new ExtendedPropertyDefinition(0x4029, MapiPropertyType.String);
                em.SetExtendedProperty(PR_ReadReceiptAddrType_W, "SMTP");
                ExtendedPropertyDefinition PR_ReadReceiptDisplayName_W = new ExtendedPropertyDefinition(0x402B, MapiPropertyType.String);
                em.SetExtendedProperty(PR_ReadReceiptDisplayName_W, "My User");
                ExtendedPropertyDefinition PR_ReadReceiptEmailAddr_W = new ExtendedPropertyDefinition(0x402A, MapiPropertyType.String);
                em.SetExtendedProperty(PR_ReadReceiptEmailAddr_W, "address@domain.com");
                em.ToRecipients.Add("glen@office365ops.onmicrosoft.com");
                em.IsReadReceiptRequested = true;
                em.SendAndSaveCopy();
    

    Cheers
    Glen

    Wednesday, November 16, 2011 2:20 AM
  • Thanks Glen. Works like a charm. The only thing I can't figure out the method to define the delivery report email address.

    Based on your answer I found this descriptions:

    https://svn.openchange.org/openchange/trunk/libmapi/property_tags.h

    http://mirror.transact.net.au/sourceforge/l/project/li/libpff/documentation/MAPI%20definitions/MAPI%20definitions.pdf

    Any idea what codes or keyword work in the delivery case?

    Thanks,

    Péter

    Wednesday, November 16, 2011 8:58 AM
  • Hi Glen,

    Two questions:

    1. Where do we write the above code to set the "ReplyRecipants"?

     EmailMessage em = new EmailMessage(service);
                em.Subject = "test";
                em.Body = new MessageBody("Test 123");
                ExtendedPropertyDefinition PR_ReadReceiptAddrType_W = new ExtendedPropertyDefinition(0x4029, MapiPropertyType.String);
                em.SetExtendedProperty(PR_ReadReceiptAddrType_W, "SMTP");
                ExtendedPropertyDefinition PR_ReadReceiptDisplayName_W = new ExtendedPropertyDefinition(0x402B, MapiPropertyType.String);
                em.SetExtendedProperty(PR_ReadReceiptDisplayName_W, "My User");
                ExtendedPropertyDefinition PR_ReadReceiptEmailAddr_W = new ExtendedPropertyDefinition(0x402A, MapiPropertyType.String);
                em.SetExtendedProperty(PR_ReadReceiptEmailAddr_W, "address@domain.com");
                em.ToRecipients.Add("glen@office365ops.onmicrosoft.com");
                em.IsReadReceiptRequested = true;
                em.SendAndSaveCopy();

    2. I need the send emails through VB6 using Outlook and i require ReplyTo property to set in the mails that are send?

    Can you please help em out.

    Thanks,

    Babita

    Wednesday, February 8, 2012 6:13 PM
  • 1. Where ? not sure what you mean by this the code i posted if for the EWS Managed API http://msdn.microsoft.com/en-us/library/dd637749(v=exchg.80).aspx

    2. I'd suggest you post that question in the Outlook forum http://social.msdn.microsoft.com/Forums/en-US/outlookdev/threads make sure you include more detail as to what version of Outlook your using and what your trying to do (eg do the from add-in etc)

    Cheers
    Glen

    Thursday, February 9, 2012 6:27 AM
  • Hi Glen,

    Looks like the delivery part is required in this round.

    So. Last time with your help I managed to change that the read recipient address is not the same as the sender address.

    EmailMessage msg = new EmailMessage(service);

    msg.IsReadReceiptRequested = true;
    msg.SetExtendedProperty(PR_ReadReceiptAddrType_W, "SMTP");
    msg.SetExtendedProperty(PR_ReadReceiptEmailAddr_W, "some@domain.com");

    The problem that I can not manage to solve, that I set:

    msg.IsDeliveryReceiptRequested = true;

    but I can't change the email address where the delivery notification is sent. Any idea?

    Thanks,

    Péter

    Tuesday, April 2, 2013 2:57 PM
  • You should be to set the  PR_REPORT_ENTRYID (PidTagReportEntryId) and PR_REPORT_NAME (PidTagReportName) properties see http://msdn.microsoft.com/en-us/library/office/cc815900.aspx which then should map to the Return-Receipt-To header http://msdn.microsoft.com/en-us/library/gg680428(v=exchg.80).aspx

    eg something like

                ExtendedPropertyDefinition PidTagReportName = new ExtendedPropertyDefinition(0x003A, MapiPropertyType.String);
                ExtendedPropertyDefinition PR_REPORT_ENTRYID = new ExtendedPropertyDefinition(0x0045,MapiPropertyType.Binary);
                Byte[] ByteVal = HexStringToByteArray("00000000812B1FA4BEA310199D6E00DD010F54020000019074006500730074002000280067006C0065006E0040006D00730067006F00700073003300360035002E006F006E006D006900630072006F0073006F00660074002E0063006F006D002900000053004D0054005000000067006C0065006E0040006D00730067006F00700073003300360035002E006F006E006D006900630072006F0073006F00660074002E0063006F006D000000");
                EmailMessage msg = new EmailMessage(service);
                msg.ToRecipients.Add("user@domain.com");
                msg.IsReadReceiptRequested = true;
                msg.SetExtendedProperty(PR_REPORT_ENTRYID, ByteVal);
                msg.SetExtendedProperty(PidTagReportName, "Glen");
                msg.IsDeliveryReceiptRequested = true;
                msg.SendAndSaveCopy();
    Cheers
    Glen
    Wednesday, April 3, 2013 6:17 AM
  • Hi Glen,

    Still not work for me.

                ExtendedPropertyDefinition PidTagReportName = new ExtendedPropertyDefinition(0x003A, MapiPropertyType.String);
                ExtendedPropertyDefinition PR_REPORT_ENTRYID = new ExtendedPropertyDefinition(0x0045, MapiPropertyType.Binary);
                Byte[] ByteVal = HexStringToByteArray("00000000812B1FA4BEA310199D6E00DD010F54020000019074006500730074002000280067006C0065006E0040006D00730067006F00700073003300360035002E006F006E006D006900630072006F0073006F00660074002E0063006F006D002900000053004D0054005000000067006C0065006E0040006D00730067006F00700073003300360035002E006F006E006D006900630072006F0073006F00660074002E0063006F006D000000");
                EmailMessage msg = new EmailMessage(service);
                msg.ToRecipients.Add("private gmail email address");
                msg.IsReadReceiptRequested = true;
                msg.SetExtendedProperty(PR_REPORT_ENTRYID, ByteVal);
                msg.SetExtendedProperty(PidTagReportName, "test gmail email address");
                msg.IsDeliveryReceiptRequested = true;

                msg.Send();

    I use the code above and didn't get emailt to 'test gmail email address' and the corporate address I get the following message (I use hungarian office, so maybe the englis version of the message is a little bit different):

    The message has been successfully delivered to the recipients or group, but the following target server not sent delivery report: private gmail email address

    It's because the gmail servers?

    Thank,

    Péter

    Wednesday, April 3, 2013 8:13 AM
  • In the meantime I tried in our corporate exchange (the recipient and the delivery report target set to inner addresses)

    Now the code looks like this:

                ExtendedPropertyDefinition PidTagReportName = new ExtendedPropertyDefinition(0x003A, MapiPropertyType.String);
                ExtendedPropertyDefinition PR_REPORT_ENTRYID = new ExtendedPropertyDefinition(0x0045, MapiPropertyType.Binary);
                Byte[] ByteVal = HexStringToByteArray("00000000812B1FA4BEA310199D6E00DD010F54020000019074006500730074002000280067006C0065006E0040006D00730067006F00700073003300360035002E006F006E006D006900630072006F0073006F00660074002E0063006F006D002900000053004D0054005000000067006C0065006E0040006D00730067006F00700073003300360035002E006F006E006D006900630072006F0073006F00660074002E0063006F006D000000");
                EmailMessage msg = new EmailMessage(service);
                msg.ToRecipients.Add("coworker_1@corporate.hu");
                msg.IsReadReceiptRequested = true;
                msg.SetExtendedProperty(PR_REPORT_ENTRYID, ByteVal);
                msg.SetExtendedProperty(PidTagReportName, "coworker_2@corporate.hu");
                msg.IsDeliveryReceiptRequested = true;

                msg.Send();

    The recipient get the message, but I get the delivery report to me@corporate.hu not coworker_2@corporate.hu.

    Péter

    Wednesday, April 3, 2013 9:26 AM
  • Okay thats stumped me you need to set the

                ExtendedPropertyDefinition PR_ReadReceiptAddrType_W = new ExtendedPropertyDefinition(0x4029, MapiPropertyType.String);
                msg.SetExtendedProperty(PR_ReadReceiptAddrType_W, "SMTP");
                ExtendedPropertyDefinition PR_ReadReceiptEmailAddr_W = new ExtendedPropertyDefinition(0x402A, MapiPropertyType.String);
                msg.SetExtendedProperty(PR_ReadReceiptEmailAddr_W, "user@domainom");

    properties to Get the Return-Receipt-To header to bet set correctly but even though I see the correct header on the Target Email System it doesn't seem to affect the behaviour. Its also completly opposite to what the documentation says it should do, maybe create a thread as a documentation bug in http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/threads and they maybe able to point to what the correct behaviour should be.

    Cheers
    Glen

     
    Thursday, April 4, 2013 7:20 AM
  • Thursday, April 4, 2013 8:22 AM