0

我编写了一个 wpf 应用程序,它通过默认登录用户发送 Outlook 邮件。

这是我的代码:

using System;
using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;

namespace FileOrganizer
{
    class Program
    {
        private void CreateMailItem()
        {
            Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            mailItem.Subject = "This is the subject";
            mailItem.To = "someone@example.com";
            mailItem.Body = "This is the message.";
            mailItem.Attachment.Add(logPath);//logPath is a string holding path to the log.txt file
            mailItem.Importance = Microsoft.Office.Tools.Outlook.OlImportance.olImportanceHigh;
            mailItem.Display(false);
        }
    }
}

我看到了这个帖子:

如何通过指定发件人地址使用 Microsoft.Office.Interop.Outlook.MailItem 发送邮件

但我在我的项目中找不到 Outlook.Accounts 选项。它只是没有出现。

有没有人有这个问题的解决方案?

我的主要目标当然是使用不同的用户发送我的邮件。

4

0 回答 0