【问题标题】:How do I open Email Meeting Template instead of Email using VBA excel如何使用 VBA excel 打开电子邮件会议模板而不是电子邮件
【发布时间】:2020-10-21 04:10:41
【问题描述】:

我创建了一些动态电子邮件,用户可以根据所述列中的数据数量发送多封电子邮件。代码本身将逐字跟随文本框并在电子邮件正文中生成,但我目前正在尝试让 Excel 打开电子邮件会议模板而不是普通电子邮件。

这里是代码。

Sub send_mass_email()
    Dim i As Integer
    Dim name, email, body, subject, copy, place, business As String
    Dim OutApp As Object
    Dim OutMail As Object
    
    body = ActiveSheet.TextBoxes("TextBox 1").Text
    
    i = 2
    'Loop down name column starting at row 2 column 1
    Do While Cells(i, 1).Value <> ""
        
        name = Split(Cells(i, 1).Value, " ")(0) 'extract first name
        email = Cells(i, 2).Value
        subject = Cells(i, 3).Value
        copy = Cells(i, 4).Value
        business = Cells(i, 5).Value
        place = Cells(i, 6).Value
        
        'replace place holders
        body = Replace(body, "C1", name)
        body = Replace(body, "C5", business)
        body = Replace(body, "C6", place)
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        With OutMail
             .to = email
             .cc = copy
             .subject = subject
             .body = body
             '.Attachments.Add ("") 'You can add files here
             .display
             '.Send
        End With
        
        'reset body text
        body = ActiveSheet.TextBoxes("TextBox 1").Text
        
        i = i + 1
    Loop
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    MsgBox "Email(s) Sent!"    
End Sub

我尝试使用 olmeeting 但出现错误:Object doesn't support this property or method

【问题讨论】:

    标签: excel vba outlook


    【解决方案1】:

    没有愚蠢的问题!

    请参考 VBA 文档here

    看来你要修改这部分代码:

    Set OutMail = OutApp.CreateItem(0)
    

    Set OutMail = OutApp.CreateItem(1)
    

    文档暗示通过将 .CreateItem 方法的参数更改为列出的值之一here,您将达到预期的效果。请注意,我尚未对其进行测试。

    【讨论】:

      猜你喜欢
      • 2014-11-07
      • 1970-01-01
      • 2010-12-18
      • 2012-05-17
      • 1970-01-01
      • 2015-08-10
      • 1970-01-01
      • 2020-01-14
      • 2012-10-10
      相关资源
      最近更新 更多