我目前想要構建VBA功能,使人們能夠使用組電子郵件地址發送電子郵件(例如,人員A的電子郵件地址爲[email protected],他是也是「學生」組的成員,並且可以使用該組的電子郵件地址發送電子郵件[email protected])使用VBA從outlook電子郵件地址發送電子郵件
我正在考慮使用VBA來構建這樣的功能。構建身體,收件人等等很容易,但是如何將發件人從現場轉移到羣組電子郵件地址?
我目前想要構建VBA功能,使人們能夠使用組電子郵件地址發送電子郵件(例如,人員A的電子郵件地址爲[email protected],他是也是「學生」組的成員,並且可以使用該組的電子郵件地址發送電子郵件[email protected])使用VBA從outlook電子郵件地址發送電子郵件
我正在考慮使用VBA來構建這樣的功能。構建身體,收件人等等很容易,但是如何將發件人從現場轉移到羣組電子郵件地址?
您是否想要發送更多內容?我對你的問題有些困惑。
Sub Mail_Workbook_1()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
' Change the mail address and subject in the macro before you run it. Or pass variables to it
With OutMail
.To = "[email protected]" 'You can also set it equal to something like TextBox1.Text or any string variable or item
.CC = ""
.BCC = ""
'Once again for the next two you can pull this from a cell, a textbox, or really anything
.Subject = "This is the Subject line"
.Body = "Hello World!"
.Attachments.Add ActiveWorkbook.FullName
' You can add other files by uncommenting the following line.
'.Attachments.Add ("C:\test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
也許您只需編輯回覆地址,以便將任何回覆發送給組?
這裏是如何,使用Outlook:
'Tools > References ... > check "Microsoft Outlook object library"
Dim outlookApp As Outlook.Application
Dim mailMsg As MailItem
Dim replyToRecipient As Recipient
Set outlookApp = CreateObject("Outlook.Application")
Set mailMsg = outlookApp.CreateItem(olMailItem)
With mailMsg
.To = "[email protected]"
Set replyToRecipient = .ReplyRecipients.Add("[email protected]") ' group adderss
replyToRecipient.Resolve
If Not replyToRecipient.Resolved Then Err.Raise 9999, , _
replyToRecipient.Address _
& " could not be resolved as a valid e-mail address."
'...
'... edit body etc. here...
'...
.Display
End With