首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用VBA从outlook中的组电子邮件地址发送电子邮件

使用VBA从outlook中的组电子邮件地址发送电子邮件
EN

Stack Overflow用户
提问于 2014-01-24 03:15:31
回答 2查看 2.6K关注 0票数 0

我目前想要构建一个VBA功能,使人们能够使用组电子邮件地址发送电子邮件(例如,person A有一个电子邮件地址a@111.com,他也是“学生”组的成员,并且可以使用组电子邮件地址发送电子邮件-学生@111.com)

我正在考虑使用VBA来构建这样一个函数。很容易构建主体、收件人等,但是如何将发件人从字段转移到组电子邮件地址呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-24 05:46:20

你想要的不仅仅是如何发送吗?我被你的问题弄糊涂了。

代码语言:javascript
复制
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
票数 0
EN

Stack Overflow用户

发布于 2014-01-24 08:14:40

也许你只需要编辑回复地址,这样任何回复都会被发送到组中?

以下是如何使用Outlook:

代码语言:javascript
复制
'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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21323763

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档