【发布时间】:2020-06-27 17:04:02
【问题描述】:
我在 Outlook 中有几个帐户。其中之一是兑换账户。其他是 IMAP
我正在尝试默认使用 IMAP..outlook 选项似乎没有帮助...因为-->
我正在使用 VBA 代码加载电子邮件内容并从 excel 触发电子邮件发送过程。
即使我将 IMAP 帐户声明为默认帐户,电子邮件也会继续使用交换帐户发送出去。有什么想法吗?
【问题讨论】:
我在 Outlook 中有几个帐户。其中之一是兑换账户。其他是 IMAP
我正在尝试默认使用 IMAP..outlook 选项似乎没有帮助...因为-->
我正在使用 VBA 代码加载电子邮件内容并从 excel 触发电子邮件发送过程。
即使我将 IMAP 帐户声明为默认帐户,电子邮件也会继续使用交换帐户发送出去。有什么想法吗?
【问题讨论】:
Outlook 对象模型为 MailItem 类提供了 SendUsingAccount 属性,该属性允许设置一个 Account 对象,该对象表示要在其下发送 MailItem 的帐户。您只需要在调用 Send 方法之前设置属性。例如:
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
【讨论】: