+ Reply to Thread
Results 1 to 2 of 2

Excel to Email - Email body from Excel cells

  1. #1
    Registered User
    Join Date
    07-16-2021
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    1

    Excel to Email - Email body from Excel cells

    Hi, I am trying to get an email sent from excell having the destination reading from a range of cells and the body showing the row where the email being sent to is located. This is the code I have done so far, which runs but nothing ends up happening:

    Sub Send_Email_4()
    Dim edress As String
    Dim subj As String
    Dim total As String
    Dim message As String
    Dim outlookapp As Object
    Dim outlookmailitem As Object
    Dim path As String
    Dim lastrow As Integer
    Dim x As Integer
    Dim header As String
    Dim header1 As String
    Dim header2 As String
    Dim header3 As String
    Dim header4 As String
    Dim header5 As String
    Dim header6 As String
    Dim header7 As String
    Dim header8 As String
    Dim data As String
    Dim Data1 As String
    Dim Data2 As String
    Dim data3 As String
    Dim data4 As String
    Dim data5 As String
    Dim data6 As String
    Dim data7 As String
    Dim data8 As String


    x = 5

    Do While Sheet1.Cells(x, 1)

    Set outlookapp = CreateObject("Outlook.Application")
    Set outlookmailitem = outlookapp.createitem(0)

    edress = Sheet1.Cells(x, 1)

    total = Sheetl.Cells(52, 10)

    subj = Sheet1.Cells(x, 2)
    header = Sheet1.Cells(4, 3)
    header1 = Sheet1.Cells(4, 4)
    header2 = Sheet1.Cells(4, 5)
    header3 = Sheet1.Cells(4, 6)
    header4 = Sheet1.Cells(4, 7)
    header5 = Sheet1.Cells(4, 8)
    header6 = Sheet1.Cells(4, 9)
    header7 = Sheet1.Cells(4, 10)

    data = Sheet1.Cells(x, 2)
    Data1 = Sheet1.Cells(x, 4)
    Data2 = Sheet1.Cells(x, 5)
    data3 = Sheet1.Cells(x, 6)
    data4 = Sheet1.Cells(x, 7)
    data5 = Sheet1.Cells(x, 8)
    data6 = Sheet1.Cells(x, 9)
    data7 = Sheet1.Cells(x, 10)


    outlookmailitem.To = edress
    outlookmailitem.cc = ""
    outlookmailitem.bcc = ""
    outlookmailitem.Subject = subj
    outlookmailitem.Body = "Dear NAFDA FS Member," & vbCrLf & _
    "Results for the annual FYR 2021 growth program are as follows," & _
    vbCrLf & header & " " & header1 & " " & header2 & " " & header3 & " " & header4 & " " & header5 & " " & header6 & " " & header7 & _
    vbCrLf & data & " " & Data1 & " & data2 &" _
    & data3 & " " & data4 & " " & data5 & _
    data6 & " " & data7 & " " _
    & vbCrLf & "Best Regards"

    outlookmailitem.display

    lastrow = lastrow + 1
    EMAILS = ""

    x = x + 1

    Loop

    End Sub

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Excel to Email - Email body from Excel cells

    Could you attached small sample file, please. Check yellow banner at the top of page.
    If we see how data are organised on sheet it will help to help you.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 02-11-2019, 08:45 AM
  2. [SOLVED] VBA to send email using data from the EXCEL including email address, subject and body text
    By ec4excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2016, 11:07 AM
  3. How to send email from excel using VBA with Cell Range (Including Images) as Email Body
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2014, 05:06 AM
  4. vba pull data from outlook body of email through email or subject of mail into excel
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2014, 04:37 AM
  5. export outlook 2007 email into excel with subject and body of email
    By akulka58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2013, 02:37 PM
  6. Replies: 0
    Last Post: 02-21-2013, 04:46 AM
  7. Replies: 2
    Last Post: 08-01-2012, 02:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1