Exchange Web服务托管Api - 将电子邮件另存为msg到磁盘 [英] Exchange Web Service Managed Api - Save an email as an msg to disk

查看:79
本文介绍了Exchange Web服务托管Api - 将电子邮件另存为msg到磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试保存通过EWS托管Api检索到的电子邮件,但在尝试打开文件时收到以下消息。

" ;无法打开文件c:\ bla \ bin ...文件可能不存在,您可能没有权限打开它,或者它可能在另一个程序中打开。右键单击包含该文件的文件夹,然后单击"属性"以检查该文件夹的权限。"

任何帮助都会受到很多关注。

请参阅下面的代码:

public static void save_entire_email_to_disk()
{
ExchangeService service = GetService();

var var findResults = service.FindItems( WellKnownFolderName.Inbox,new ItemView(10));
foreach(在findResults中的var结果)
{
如果(结果是EmailMessage)
{
var var =结果作为EmailMessage;
message.Load(new PropertySet(ItemSchema.MimeContent));

MimeContent mc = message.MimeContent;
FileStream oFileStream = new FileStream(" Test.msg" ;,FileMode.Create);

oFileStream.Write(mc.Content,0,mc.Content.Length);

oFileStream.Close();
}
}
}

干杯,

Hi,
I am trying to save an email that I have retrieved via the EWS managed Api but get the following message when I try and open the file.

"Cannot open file c:\bla\bin... The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contails the file, and then click Properties to check your permissions for the folder. "

Any help will be much appriciated.

See code below:

public static void save_entire_email_to_disk()
{
    ExchangeService service = GetService();

    var findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10));
    foreach (var result in findResults)
    {
        if (result is EmailMessage)
        {
            var message = result as EmailMessage;
            message.Load(new PropertySet(ItemSchema.MimeContent));
           
            MimeContent mc = message.MimeContent;
            FileStream oFileStream = new FileStream("Test.msg", FileMode.Create);

            oFileStream.Write(mc.Content, 0, mc.Content.Length);
            oFileStream.Close();
        }
    }
}

Cheers,

Zi

推荐答案

如果我将其保存的扩展名更改为(.msg - >的.eml)。我能够进入eml并查看邮件和内容但不幸的是我需要该文件是一个msg not和eml。

If I change the extension that it saves to (.msg -> .eml). I am able to get into the eml and view the mail and the contents but unfortunately I need the file to be a msg not and eml.

为什么我在收到该消息时我试着打开msg ???我错过了一个技巧吗?

Why do I get that message when I try and open the msg??? Am I missing a trick?

任何指针都会很棒!

Zi


这篇关于Exchange Web服务托管Api - 将电子邮件另存为msg到磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆