【问题标题】:Replying to Email based off Excel Value根据 Excel 值回复电子邮件
【发布时间】:2018-03-17 11:50:38
【问题描述】:

我的自动化程序遇到了障碍。将在下面概述:

  1. 创建的表格可在线使用并允许用户填写 Excel 表格并单击提交(提交后将发送电子邮件并将字段转移到共享驱动器中的跟踪器)
  2. 电子邮件将显示在收件箱中,Outlook 规则将根据主题行将电子邮件分类到不同的文件夹中

    现在是我卡在的部分

    在我的跟踪器中,我有一些规则来做出决定。简而言之,基于特定的单元格值(H 列),我需要使用预定义的模板(模板有 3 个从用户表单引用的字段)回复原始电子邮件。

    我遇到的问题是如何使用自动决策回复 Outlook 中的原始电子邮件?

    请帮忙:)

【问题讨论】:

  • @braX 唯一的问题是我的预定义模板将使用原始 excel 用户表单中的 3 个字段。以上解决方案只会回复电子邮件不? VBA 有点新,但我认为在收到新电子邮件后,我可能需要触发另一个宏?
  • 只是有点不确定如何触发/打开我的 excel 文件
  • @selvend2 在我看来这里有不止 1 个问题 - 你能说得更具体一点吗? 你到底想做什么?
  • 1.在 Excel 中创建电子表单 2. 使用宏发送电子邮件并将表单字段转置到另一个 Excel 文件 3. 使用 Outlook 规则自动对电子邮件进行排序 4. 使用基于表单字段的模板回复电子邮件(因此模板会有所不同每种情况)

标签: vba excel outlook


【解决方案1】:

所以,如果单元格具有特定值,您想发送一封电子邮件,对吧。请尝试以下脚本。

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
        If IsNumeric(Target.Value) And Target.Value > 200 Then
            Call YourMacroName
        End If
    End If
End Sub

Sub Mail_small_Text_Outlook()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Excel 2000-2016
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "Hi there" & vbNewLine & vbNewLine & _
              "Cell A1 is changed" & vbNewLine & _
              "This is line 2" & vbNewLine & _
              "This is line 3" & vbNewLine & _
              "This is line 4"

    On Error Resume Next
    With OutMail
        .To = "ron@debruin.nl"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = strbody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Display   'or use .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

https://www.rondebruin.nl/win/s1/outlook/bmail9.htm

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 2019-04-18
    • 2015-09-20
    • 1970-01-01
    • 2021-10-07
    相关资源
    最近更新 更多