我目前想要构建一个VBA功能,使人们可以使用群组电子邮件地址发送电子邮件(例如,A人的电子邮件地址为a@111.com,他也是“学生”群组的成员,并且可以访问使用群组电子邮件地址student@111.com发送电子邮件)
我正在考虑使用VBA来构建这样的功能。构建正文,收件人等很容易,但如何将发件人,即从字段转移到群组电子邮件地址?
答案 0 :(得分:0)
你想要的不仅仅是如何发送它吗?我对你的问题感到有些困惑。
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 = "tom@google.com" '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
答案 1 :(得分:0)
也许您只需要编辑回复地址,以便将任何回复发送给该组?
以下是使用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 = "abc@111.com"
Set replyToRecipient = .ReplyRecipients.Add("group@111.com") ' 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