MailItem.SendUsingAccount属性返回或设置一个Account对象,该对象表示要发送MailItem
的帐户。例如:
private void SendUsingAccountExample()
{
Outlook.MailItem mail = Application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
mail.Subject = "Our itinerary";
mail.Attachments.Add(@"c:\travel\itinerary.doc",Outlook.OlAttachmentType.olByValue,Type.Missing,Type.Missing);
Outlook.Account account = Application.Session.Accounts["Hotmail"];
mail.SendUsingAccount = account;
mail.Send();
}
有关更多信息,请参见Send a mail item by using a Hotmail account。
请记住,在这种情况下,应在Outlook中配置另一个帐户。
SentOnBehalfOfName属性仅在Exchange配置文件/帐户的情况下才有意义。此外,您需要具有所需的权限才能代表他人发送。有关类似的讨论,请参见Issue with SentOnBehalfOfName。
如果在配置文件中配置了多个帐户,则可以使用SendUsingAccount属性,该属性允许一个Account对象,该对象代表要发送MailItem的帐户。
Sub SendUsingAccount()
Dim oAccount As Outlook.account
For Each oAccount In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As Outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("someone@example.com")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub
本文链接:https://www.f2er.com/3157348.html