如何使用单元格值创建Excel电子邮件按钮?

如何发送具有特定单元格值的电子邮件?

当前正在处理Excel工作表。我要做的是创建两个按钮,因此当我按下按钮时,它会向我的同事发送一封电子邮件,其中包含我在特定单元格中的值。我在网上看到很多“如何在Excel中使用VBA发送电子邮件”的信息,但是我不知道如何在电子邮件中包含这些值。

例如,我要在正文电子邮件中执行以下操作:

你好“ assname”

上周,我们的团队整体生产力为“ allProd”。您在“ weekStart”到weekEnd”这一周的生产率和排名是“ assprod”,而您的排名是“ rankNum”。

最好的问候

MySignature

我要包含的信息的位置是这样的

Spreadsheet Name "November"
assname is located in A4 of the spredsheet 
allProd is located in G3 of the spreadsheet 
weekStart is located in C2 of the spreadsheet 
allEnd is located in E2 of the spreadsheet 
assprod is located in E4 of the spreadsheet 
rankNum is located in F4 of the spreadsheet 

我发现的当前VBA代码是:

Private Sub CommandButton1_Click()

    Dim xOutApp As Object
    Dim xOutMail As Object
    Dim xMailBody As String


    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xOutMail = xOutApp.CreateItem(0)
       xMailBody = "Body content" & vbNewLine & vbNewLine & _
              "This is line 1" & vbNewLine & _
              "This is line 2"
                  On Error Resume Next
    With xOutMail
        .To = "my work email goes here"
        .CC = ""
        .BCC = ""
        .Subject = "Your Producitvity for this week"
        .Body = xMailBody
        .Display   'or use .Send
    End With
    On Error GoTo 0
    Set xOutMail = Nothing
    Set xOutApp = Nothing
End Sub

另一个Button /电子邮件在本质上是相同的,但包括我在电子表格中向部门经理创建的带有图表的所有联系人。

你好团队

上个月,我们的团队整体生产力为“ allmoProd”。请看下图 “ mographProd”

最好的问候

MySignature

iceman4019 回答:如何使用单元格值创建Excel电子邮件按钮?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3162353.html

大家都在问