I am trying to create a rule by using EWS API for a shared mailbox. For that I am using the following code:
Rule newRule = new Rule();
newRule.DisplayName = "Forward";
forwardEmailTo= "xxx#hotmail.com";
newRule.Conditions.SentToAddresses.Add("Forward", "sharedmailbox#myexchangedomain.online");
newRule.Actions.ForwardToRecipients.Add(forwardEmailTo);
CreateRuleOperation createMoveIfFromSalesRule = new CreateRuleOperation(newRule);
service.UpdateInboxRules(new RuleOperation[] {createMoveIfFromSalesRule}, true);
But unfortunately the rule is not created on the shared mail box (sharedmailbox#myexchangedomain.online), it is being created on the principal mail box account.
What Am I doing wrong?
The UpdateInboxRules Method has an overload for the Mailbox you want to create the rule in so your method call should be
service.UpdateInboxRules(new RuleOperation[] {createMoveIfFromSalesRule,"TargetMailbxo#domain.com"}, true);
Related
In my outlook web add-in I use Office.js's getCallbackTokenAsync
to get the token before connecting to EWS in my asp.net back end.
ExchangeService service = new ExchangeService();
service.Url = new Uri(mailItem.ewsUrl);
service.Credentials = new OAuthCredentials(mailItem.ewsToken);
PropertySet ps = new PropertySet(
ItemSchema.Subject,
);
_email = EmailMessage.Bind(service, new ItemId(mailItem.itemID),ps);
//the following throws error
ConversationResponse response = service.GetConversationItems(convId,
properties,
null,
foldersToIgnore,
ConversationSortOrder.TreeOrderDescending);
Seems like this GetConversationItems method is not allowed when I used the token retrieved by Office.js to initialize the EWS service. I tried to updated the manifest permission to the highest level to ReadWriteMailBox but still not working. Seems like I can only use Office.js to call EWS?
The token you get from getCallbackTokenAsync is only used to retrieve attachments on the current item or on the current item.
For more information, please see the following link:
getCallbackTokenAsync
Best Regards,
Evan
I'm sending documents electronically successfully within an app using DocuSign.
Depending on who's logged into the app I was hoping to change the sender email address..so they can get notified of any responses via email.
Is this possible using EnvelopesAPI, I don't have to create an account with each user's email address, do I?
Thanks,
In your c# try adding the below code, This overrides the reply to in an email.
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSettings = new EmailSettings();
envDef.EmailSettings.ReplyEmailAddressOverride = YOUR_LOGGEDIN_USEREMAIL;
I am analyzing a users Exchange mailbox with calls to the ExchangeService. This tool needs to run on the client environment periodically and by ommiting the credentials to the service I am connecting to the Exchange Service as the logged in Windows User. I can succesfully loop thrue the folders and items.
Now I want tot retrieve the information about the mailbox being used. Username and (main) E-mail should suffice. But I cannot find anything about how to retrieve this information. Every example provides credentails for the user, or auto-discovering the Exchange service from the e-mail adres. I do not want the user to configure anything :-).
Any suggestions?
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri("https://FQDN/EWS/Exchange.asmx");
???
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.SentItems, new ItemView(100)); // this works
I've tried using service.ResolveName, but that can give multiple answers, even using Environment.UserName
The easiest method to do this is to use ConvertId operation and use unresolvable address (blah#blah.com always works for me) in the Mailbox element. Exchange should convert this to the actual Mailbox in the response. eg
Folder chk = Folder.Bind(service, WellKnownFolderName.Inbox);
AlternateId aiItem = new AlternateId();
aiItem.Mailbox = "Blah#Blah.com";
aiItem.UniqueId = chk.Id.UniqueId;
aiItem.Format = IdFormat.EwsId;
String CasServer = service.Url.Host.ToString();
AlternateIdBase caid = service.ConvertId(aiItem, IdFormat.HexEntryId);
Console.WriteLine(((AlternateId)caid).Mailbox);
Cheers
Glen
I'm using Exchange Web Services to access contact records in a public folder. I need to pull a custom column, "Client Contact Management", created for a view in that folder. The custom column was created in the user interface.
I've already used the ExtendedPropertyDefinition class before on properties that I have created on my own through code. Is that what I'm supposed to use in this case and if so then how do I get the guid for the custom column?
I finally found the answer on this thread from David Sterling on the microsoft exchange server forums. His example (copied below) shows how to do things using EWS directly and using the managed api.
// via autogenerated proxy classes
PathToExtendedFieldType hairColorPath = new PathToExtendedFieldType();
hairColorPath.DistinguishedPropertySetId = DistinguishedPropertySetType.PublicStrings;
hairColorPath.DistinguishedPropertySetIdSpecified = true;
hairColorPath.PropertyName = "HairColor";
hairColorPath.PropertyType = MapiPropertyTypeType.String;
// via the Client API
ExtendedPropertyDefinition hairColor = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.PublicStrings,
"HairColor",
MapiPropertyType.String);
Here is what I did using the managed api for my own problem. The key is using the DefaultExtendedPropertySet.PublicStrings which is where outlook stores the custom view column.
ExtendedPropertyDefinition _clientContactManagementPropertyDefinition =
new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.PublicStrings,
"Client Contact Management",
MapiPropertyType.Boolean
);
Currently a piece of our application creates and saves new mail messages to a user's drafts folder using Exchange Web Services. We would like to automatically append the user's default signature to these messages when creating them, but I have not been able to find a way to access the signature to append it to the body. The email message is currently created with the following code:
CreateItemType createEmailRequest = new CreateItemType();
createEmailRequest.MessageDisposition = MessageDispositionType.SaveOnly;
createEmailRequest.MessageDispositionSpecified = true;
DistinguishedFolderIdType draftsFolder = new DistinguishedFolderIdType();
draftsFolder.Id = distinguishedFolderIdNameType;
createEmailRequest.SavedItemFolderId = new TargetFolderIdType();
createEmailRequest.SavedItemFolderId.Item = draftsFolder;
MessageType emailMessage = new MessageType();
emailMessage.Subject = subject;
emailMessage.Body = new BodyType();
emailMessage.Body.BodyType1 = bodyType;
emailMessage.Body.Value = body;
emailMessage.Sensitivity = SensitivityChoicesType.Normal;
emailMessage.SensitivitySpecified = true;
createEmailRequest.Items = new NonEmptyArrayOfAllItemsType();
createEmailRequest.Items.Items = new ItemType[1];
createEmailRequest.Items.Items[0] = emailMessage;
Any ideas on how to get the current user's default signature and append it to the body the email?
The signatures in Outlook are a client-side feature and thus can't be accessed from Exchange Web Services. In fact I believe the signatures are actually stored in the users profile on the machine - I know I have to redo my signature when moving from one machine to another (I'm on Outlook/Exchange 2010).
In Exchange 2010 You can create a transport rule that can access user information, but there's not a way to use the Outlook signature information that I'm aware of.