即使在发送后,以编程方式为 Outlook 生成的电子邮件也会卡在草稿文件夹中!

发布于 2024-11-19 01:43:58 字数 936 浏览 0 评论 0原文

因此,我一直通过 C# 应用程序为我工作的公司生成电子邮件。电子邮件生成得很好。唯一的小问题是,当它们从草稿文件夹发送时,它们不会移动到已发送文件夹。它们保留在草稿文件夹中。

我不知道这是否是电子邮件上的设置

这是我使用的代码:

Outlook.Application objOutlook= new Outlook.Application();

        // Creating a new Outlook Message from the Outlook Application Instance
        // Assigns the "TO", "CC" and "BCC" Fields
       // Assigns the Subject Field

        Outlook._NameSpace oNameSpace = objOutlook.GetNamespace("MAPI");
        Outlook.MAPIFolder folder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
        String body;
        Outlook.MailItem mic = (Outlook.MailItem)(objOutlook.CreateItem(Outlook.OlItemType.olMailItem));
         mic.To = receiver;
         //Code that fills in body and what not of the email
         mic.Subject = subject;
         mic.HTMLBody = body;
         mic.SaveSentMessageFolder = folder
         mic.Save();

也许有人有想法?感谢您的帮助!

So I have been generating emails through a C# application for the company I work for. Emails are generated fine. The only little issue is that when they are sent from the drafts folder, they are not moved to the sent folder. They stay in the drafts folder.

I didnt know if it was a setting on the email or not

Here is the code I used:

Outlook.Application objOutlook= new Outlook.Application();

        // Creating a new Outlook Message from the Outlook Application Instance
        // Assigns the "TO", "CC" and "BCC" Fields
       // Assigns the Subject Field

        Outlook._NameSpace oNameSpace = objOutlook.GetNamespace("MAPI");
        Outlook.MAPIFolder folder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
        String body;
        Outlook.MailItem mic = (Outlook.MailItem)(objOutlook.CreateItem(Outlook.OlItemType.olMailItem));
         mic.To = receiver;
         //Code that fills in body and what not of the email
         mic.Subject = subject;
         mic.HTMLBody = body;
         mic.SaveSentMessageFolder = folder
         mic.Save();

Maybe some one has a idea? Thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深如许 2024-11-26 01:43:59

我相信它在发送后将电子邮件保存在草稿文件夹中,因为您要求它将其保存在那里。

Outlook.MAPIFolder folder
    = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
...
mic.SaveSentMessageFolder = folder

根据 MSDN

...一个 MAPIFolder 对象,代表发送后将在其中保存电子邮件副本的文件夹。

I believe it is saving the emails in the Drafts folder after being sent because you asked it to save it there.

Outlook.MAPIFolder folder
    = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);
...
mic.SaveSentMessageFolder = folder

Per MSDN:

...a MAPIFolder object that represents the folder in which a copy of the e-mail message will be saved after being sent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文