我目前想要构建一个VBA功能,使人们能够使用组电子邮件地址发送电子邮件(例如,person A有一个电子邮件地址a@111.com,他也是“学生”组的成员,并且可以使用组电子邮件地址发送电子邮件-学生@111.com)
我正在考虑使用VBA来构建这样一个函数。很容易构建主体、收件人等,但是如何将发件人从字段转移到组电子邮件地址呢?
发布于 2014-01-24 05:46:20
你想要的不仅仅是如何发送吗?我被你的问题弄糊涂了。
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发布于 2014-01-24 08:14:40
也许你只需要编辑回复地址,这样任何回复都会被发送到组中?
以下是如何使用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 Withhttps://stackoverflow.com/questions/21323763
复制相似问题