使用Excel VBA选择非默认发件人



如何使用Excel VBA从辅助Outlook帐户发送?

With OutMail
.to = Text(1)
.CC = Text(2)
.BCC = ""
.Subject =text(3)
.HTMLBody = Text(10)
.Display '.send
End With

我试过了;。来自";。

下面是我用来从VBA发送电子邮件的一个非常通用的sub
它需要三个参数:

  • OutAppOutlook.Application对象
  • SendFromAddress是一个字符串变量,包含要发送的地址
  • OutMail是当前的mailitem对象,您已经将其作为查看代码的变量
'Sender Address
If Len(SendFromAddress) > 0 Then
'if directly signed into the account:
For a = 1 To OutApp.Session.accounts.Count
If LCase(OutApp.Session.accounts.Item(a)) Like LCase(SendFromAddress) Then
Outmail.sendusingaccount = OutApp.Session.accounts.Item(a)
SendFromAddress = ""
Exit For
End If
Next
'If not directly signed in (shared mailbox):
If Len(SendFromAddress) > 0 Then Outmail.SentOnBehalfOfName = SendFromAddress
End If

最新更新