1
votes

Option I want to use when sending the email is accessed in outlook. Permission option

I need to set Do not forward permission of EmailMessage object in Microsoft exchange service code but I am not able to set it to true.

        ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
        service.Credentials = new WebCredentials("abc", "xyz", "bbb");

        service.AutodiscoverUrl("[email protected]", RedirectionUrlValidationCallback);
        //service.Url = new System.Uri("https://exserver.yourdomain.com/EWS/Exchange.asmx");

        // Get the GUID for the property set.
        Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");

        // Create a definition for the extended property.
        ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, 1, MapiPropertyType.Integer);
        // Add the extended property to an e-mail message object named "message".
       // message.SetExtendedProperty(extendedPropertyDefinition, DateTime.Now.AddDays(2).ToString());

        // Save the e-mail message.
        //message.SendAndSaveCopy();
        MailItem objm = new MailItem();

        EmailMessage email = new EmailMessage(service);
        email.ToRecipients.Add("[email protected]");
        email.Subject = "Test Message";
        email.Body = new MessageBody("Message message sent via EWS Managed API");
        email.SetExtendedProperty(extendedPropertyDefinition, OlPermission.olDoNotForward);

        //email.ConversationTopic = (AllowedResponseActions)OlPermission.olDoNotForward;
        email.Send();

I have searched google but did not find anything related to above query.

Any help would be appreciated.

OUTLOOK object I do this with MailItem object and the from id is outlook client email which is not correct i need to do this for other address.

Outlook.Application oApp = new Outlook.Application(); // Create a new mail item. Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); oMsg.HTMLBody = "Hi"; //Subject line oMsg.Subject = "Outlook client test email"; oMsg.Recipients.Add("[email protected]"); oMsg.Permission = OlPermission.olDoNotForward; oMsg.Send();

1

1 Answers

1
votes

This requires that you set e PidLidVerbStream Property on a message which is documented in the http://msdn.microsoft.com/en-us/library/ee218541(v=exchg.80).aspx there is an example in http://gsexdev.blogspot.com.au/2014/09/sending-noreply-noreplyall-noforward.html

Cheers Glen