0
Exchange Web Services 2010中是否可以通过任何电子邮件地址在邮箱中创建邮件?任何电子邮件地址的EWS CreateItemResponse
所以情况是这样的; 用户收到的电子邮件, 服务勺子在SQL邮件并存储(存储消息为XML) 电子邮件然后从邮箱 时间过得删除... 服务需要电子邮件的SQL版本,并创建返回到原始邮箱
我们之前遇到了一个交换安全问题,它不允许我们使用我们域外任何人的发件人对象创建电子邮件。例如[email protected]工作正常,但[email protected]不起作用。
我明显可以看到与解除此限制相关的安全风险,但这是我需要构建的系统的要求。
用于创建消息的实际代码位于此处(大部分代码均取自MSDN);
public void CreateEmail(string FromAddress, MessageType message)
{
ExchangeServiceBinding esb = getExchangeServiceBinding(FromAddress);
// Create the CreateItem request.
CreateItemType createItemRequest = new CreateItemType();
// Specifiy how the created items are handled
createItemRequest.MessageDisposition = MessageDispositionType.SendAndSaveCopy;
createItemRequest.MessageDispositionSpecified = true;
// Specify the location of sent items.
createItemRequest.SavedItemFolderId = new TargetFolderIdType();
DistinguishedFolderIdType sentitems = new DistinguishedFolderIdType();
sentitems.Id = DistinguishedFolderIdNameType.sentitems;
createItemRequest.SavedItemFolderId.Item = sentitems;
// Create the array of items.
createItemRequest.Items = new NonEmptyArrayOfAllItemsType();
// Create a single e-mail message.
MessageType newmessage = new MessageType();
//Can't seem to restore the original message.
//If part of the email is being lost when restored then it's happening here.
//import original message into newmessage
newmessage.Subject = message.Subject;
newmessage.Body = message.Body;
newmessage.ItemClass = message.ItemClass;
newmessage.Sender = message.Sender;
newmessage.ToRecipients = message.ToRecipients;
newmessage.Sensitivity = message.Sensitivity;
newmessage.ExtendedProperty = message.ExtendedProperty;
newmessage.DateTimeSent = message.DateTimeSent;
newmessage.IsRead = true;
// Add the message to the array of items to be created.
createItemRequest.Items.Items = new ItemType[1];
createItemRequest.Items.Items[0] = newmessage;
try
{
// Send the request to create and send the e-mail item, and get the response.
CreateItemResponseType createItemResponse = esb.CreateItem(createItemRequest);
// Determine whether the request was a success.
if (createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
{
throw new Exception(createItemResponse.ResponseMessages.Items[0].MessageText);
}
else
{
Console.WriteLine("Item was created");
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}