通过outlook发送电子邮件时遇 [英] Problem sending email through outlook

查看:173
本文介绍了通过outlook发送电子邮件时遇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Outlook 2010发送电子邮件。



0)我在DoD网络上,Outlook连接到Exchange服务器。



1)Outlook已打开,我目前已登录(我们在此处使用CAC卡进行访问,我们正在使用Active Directory)。



我收到以下COM异常:



操作已中止(HRESULT异常: 0x80004004(E_ABORT))



如下所示:



I'm trying to send an email through Outlook 2010.

0) I'm on a DoD network and Outlook is connected to an Exchange server.

1) Outlook is open, and I'm currently logged in (we use CAC cards here for access, and we're using Active Directory).

I'm getting the following COM exception:

Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

at the line indicated below:

public void SendEmails(List<VMReportItem> list)
{
    OUTLOOK.Application  app;
    OUTLOOK.NameSpace    ns;
    OUTLOOK.MAPIFolder   inbox;
    OUTLOOK.AddressEntry currentUser;
    OUTLOOK.MailItem     mailItem;

    try
    {
        app         = new OUTLOOK.Application();
        ns          = app.GetNamespace("MAPI");
        inbox       = ns.GetDefaultFolder(OUTLOOK.OlDefaultFolders.olFolderInbox);

        // EXCEPTION THROWN HERE when I try to get the current user CurrentUser
        currentUser = app.Session.CurrentUser.AddressEntry; 

        if (currentUser.Type == "EX")
        {
            foreach (VMReportItem item in list)
            {
                mailItem = this.CreateOutlookMail(app, item);
                mailItem.Send();
                while (!mailItem.Sent)
                {
                    Thread.Sleep(1000);
                }
            }
        }
    }
    catch (Exception ex)
    {
    }
}





我尝试过:



我尝试删除currentUser代码,但是当代码尝试执行 mailItem.Send()时,我得到相同的异常。但是,我确实看到一个新的窗口弹出窗口,其中包含我要发送的电子邮件。



为了完整起见, CreateMail 方法如下所示:





What I have tried:

I tried removing the currentUser code, but I get the same exception when the code tries to execute mailItem.Send(). HOWEVER, I do see a new window popup with the email I'm trying to send.

In the interest of completeness, the CreateMail method is shown below:

blic OUTLOOK.MailItem CreateOutlookMail(OUTLOOK.Application app, VMReportItem item)
{
    StringBuilder body = new StringBuilder();
    body.AppendLine(item.Body).AppendLine();
    body.AppendLine(this.RecipientNotice).AppendLine();
    body.AppendLine(this.QuestionsNotice).AppendLine();

    OUTLOOK.MailItem  mail = app.CreateItem(OUTLOOK.OlItemType.olMailItem) as OUTLOOK.MailItem;
    mail.Subject = item.Subject;
    mail.To      = "myaddress@mydomain";
    mail.Body    = body.ToString();
    mail.Attachments.Add(System.IO.Path.Combine(this.ReportPath,item.Attachment));
    mail.Display(false);
    return mail;
}

推荐答案

我认为问题是组策略设置。为了解决这个问题,我正在使用互操作服务来查找新的电子邮件窗口并单击发送按钮。
I think the problem is a group policy setting. To get around it, I'm using interop services to find the new email window and click the send button.


这篇关于通过outlook发送电子邮件时遇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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