0

我有此代码可以根据单元格 a 中的更改发送和发送电子邮件,但是我希望在电子邮件正文中包含其他单元格的内容,以便更具体地为最终用户定位问题。我想不出针对我想要的特定细胞的最佳方法。任何帮助,将不胜感激!

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A1000], Target) Is Nothing Then
    Set olApp = CreateObject("Outlook.application")
    Set M = olApp.CreateItem(olMailItem)
   Dim rngTo As Range
    Dim rngBody As Range
    Dim objOutlook As Object
    Dim objMail As Object
    Dim Issues As String
    Dim Desc As String
    Issues = Target.row


    With ActiveSheet
        'here is where i'm trying to get the contents of "F"
        Desc = Range("F" & Issues)
        Set rngBody = Intersect([A2:A1000], Target)
    End With
    rngBody.Copy

    With M
        .Subject = "Issue Tracker Has Changed"
        .Body = "The Status of Your Issue" & Desc & " Has Changed to " & rngBody
        .Recipients.Add "jane.doe@whatever.org"
        .Send
    End With
End If
End Sub

在此处输入图像描述

4

1 回答 1

0

我通过获取 Target 的行值并将其与我需要数据的列结合起来解决了这个问题,并将其作为正文中的字符串返回。

    Dim Issues As String
    Dim Desc As String
    Issues = Target.row

    Desc = Range("F" & Issues)


.Body = "The Status of Your Issue" & Desc & " Has Changed to " & rngBody.Value

通过添加这些行,我能够完成我遇到的问题

于 2013-08-09T17:24:40.580 回答