How to set/access outlook DoNotForward property in Microsoft exchange service

给你一囗甜甜゛ 提交于 2020-01-06 03:45:31

问题


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("xyz@abc.com", 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("abc@xyz.com");
        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("xyz@abc.com"); oMsg.Permission = OlPermission.olDoNotForward; oMsg.Send();


回答1:


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



来源:https://stackoverflow.com/questions/36067768/how-to-set-access-outlook-donotforward-property-in-microsoft-exchange-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!