1

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();

gaurav
  • 11
  • 3

1 Answers1

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

Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • Option I want to use when sending the email is accessed in outlook permission options which restrict to user to get screenshots, forwarding and copy of that email content. – gaurav Mar 18 '16 at 06:08
  • If your talking about RMS there is nothing in EWS to help you do that its pretty complicated as it involves having the the RMS certificates and being enrolled in the RMS service. I would suggest you use the Outlook Object Mobel instead as this will allow you to use the Outlook RMS clients which handles the Certificate enrolment etc see https://msdn.microsoft.com/en-us/library/office/ff863622.aspx – Glen Scales Mar 18 '16 at 06:19
  • How would i assigne outlook object to EWS or use to send email via any other email address which is not outlook enabled, with help of outlook mailitem object Please share lines of code.. – gaurav Mar 18 '16 at 10:31
  • You don't you need to do everything in regards to the encryption of the message using the Outlook OOM as the API to do this EWS has no ability to handle the underlying encryption. – Glen Scales Mar 18 '16 at 21:24
  • My requirement is to send email with Do not forward permission in outlook via a EWS or SMTP. so could you please tell me the sets to achieve the same and if not then why. – gaurav Mar 21 '16 at 10:01
  • I don't have a solution for what you are trying to do the way you are trying to do it. The place I suggest you start is understand what RMS is how it works and also its limitations so your question should have been "I want to send an RMS message using EWS or SMTP". The "Do not forward permission" is an RMS Permission . As I've mentioned there is no Server side functionality in EWS to do the RMS encryption of messages you will need to using something like the RMS SDK https://msdn.microsoft.com/en-us/library/windows/desktop/dn758244(v=vs.85).aspx its complex – Glen Scales Mar 22 '16 at 01:38