Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 30098

How to create excel email button using cell values?

$
0
0

How can I send email with specific cell values?

Currently working on a excel sheet. What I want to do is create two Buttons so when I press the button it send an email to my associate with the value I have in specific cells. I've seen online plenty of "how to send email using VBA in Excel", However I dont know how to include the values inside the email.

For example What I want to do is in the body email have this:

Hello "assName"

Last week we have a team Overall Productivity of "allProd". Your productivity and ranking for the week "weekStart" to weekEnd" is "assProd" and your ranking was "rankNum".

Best Regards

MySignature

The Location of the information I want include is like this

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 

The current VBA code I found is this:

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

The other Button/email is bassically the same but including all the associates with a graph I have created in the spreadsheet to the managers of the department.

Hello Team

Last month we have a team Overall Productivity of "allmoProd". Please see the following graph "mographProd"

Best Regards

MySignature


Viewing all articles
Browse latest Browse all 30098

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>