gpt4 book ai didi

c# - 如何在使用 Interop 从 C# 发送电子邮件时从 Outlook 中的多个配置文件中进行选择

转载 作者:行者123 更新时间:2023-11-30 16:58:44 26 4
gpt4 key购买 nike

我从“http://www.codeproject.com/Tips/165548/C-Code-snippet-to-send-an-Email-with-attachment-fr”中找到了这段代码

// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();

// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

// Set HTMLBody.
oMsg.HTMLBody = "Test"

//Subject line
oMsg.Subject = "Test Sub";

// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;

// Change the recipient in the next line if necessary.
Outlook.Recipient oRecip;

oRecip = (Outlook.Recipient)oRecips.Add(UserID);
oRecip.Resolve();

oRecip = (Outlook.Recipient)oRecips.Add(Recipients[i]);
oRecip.Resolve();

// Send.
oMsg.Send();

}

如果我在 Outlook 中配置了几个配置文件,我需要知道如何从特定的 Outlook 配置文件发送邮件。

提前致谢,阿维鲁普。

最佳答案

其实我从另一个post找到了答案.我们需要为不同的帐户设置一个配置文件名称,以下代码将完成这项工作:

Outlook.Account account = Application.Session.Accounts["MyOtherAccount"];

关于c# - 如何在使用 Interop 从 C# 发送电子邮件时从 Outlook 中的多个配置文件中进行选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24903171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com