とエクスポートされた電子メールをインポートします。ほとんどの場合、電子メールは.emlまたは.msg形式でインポートできます。私はあなたに.emlファイルのガイダンスを提供することができます。あなたのアーカイブサーバーで
あなたは電子メールの.emlファイルのバックアップを取得することもできますし、テストの目的のために見通しデスクトップ/ MozillaのThunderbirdのからのメールをエクスポートすることにより、1を生成することができます。
今、あなたはあなたが何このメソッドが行うことはそれがアップロードされ、次のコード
void main()
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
// Get the information of the account
service.Credentials = new WebCredentials("account email here", "account password here");
service.AutodiscoverUrl("account email here", RedirectionUrlValidationCallback);
UploadMIMEEmail(service);
}
public static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
private static void UploadMIMEEmail(ExchangeService service)
{
EmailMessage email = new EmailMessage(service);
string emlFileName = @"E:\asad.eml";
using (FileStream fs = new FileStream(emlFileName, FileMode.Open, FileAccess.Read))
{
byte[] bytes = new byte[fs.Length];
int numBytesToRead = (int)fs.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
int n = fs.Read(bytes, numBytesRead, numBytesToRead);
if (n == 0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
// Set the contents of the .eml file to the MimeContent property.
email.MimeContent = new MimeContent("UTF-8", bytes);
}
// Indicate that this email is not a draft. Otherwise, the email will appear as a
// draft to clients.
ExtendedPropertyDefinition PR_MESSAGE_FLAGS_msgflag_read = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer);
email.SetExtendedProperty(PR_MESSAGE_FLAGS_msgflag_read, 1);
// This results in a CreateItem call to EWS. The email will be saved in the Inbox folder.
email.Save(WellKnownFolderName.Inbox);
}
を利用することができ、Microsoft ExchangeのWebサービス
のために実際に管理されているNugetパッケージMicrosoft.Exchange.WebServices APIを使用することができますエクスポートされた.emlに正確に見つかったすべての電子メールデータを含むインポートされた電子メールとしてExchange Serverに電子メールを送信します。
サーバーがドメイン内/ローカルで実行しているExchange場合、あなたはまた、あなたが既定の資格情報を使用してログインしたいならば、あなたは
service.UseDefaultCredentials = true;
を指定することができます。また
service.Url = new Uri("https://computername.domain.contoso.com/EWS/Exchange.asmx");
によって為替URLを指定することができます詳細は下記をご覧ください。
https://msdn.microsoft.com/en-us/library/office/dn672319(v=exchg.150).aspx#bk_importproperties
https://code.msdn.microsoft.com/how-to-import-vcard-files-ffa0ff50
ああ、行います。一方、そのような機能を提供する最も近いAPIは何ですか? EWS Managed APIはそのトリックですか? – lolski
特に、インポートするMIMEストリームがある場合、EWSはこれを実行できます。https://msdn.microsoft.com/en-us/library/office/dn672319(v=exchg.150).aspx –