+ Reply to Thread
Results 1 to 5 of 5

Automating emails and content from excel via outlook

Hybrid View

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Automating emails and content from excel via outlook

    Hello! I haven't posted for a long time, last time I was quite overwhelmed by the help received so here's hoping for something similar!

    I have a large database of current prospects, I would like to send them emails by the click of a link from excel that would then send or open an email in Outlook.

    I would like the body of the email to pull data, i.e. first name, company name and country.

    Does this make sense?

    Thank you so much, Tom

  2. #2
    Registered User
    Join Date
    04-29-2013
    Location
    Ontario, Canada
    MS-Off Ver
    MS Office 2010
    Posts
    80

    Re: Automating emails and content from excel via outlook

    Hi Tom,

    I have a few questions before I present you with a solution:
    • How are the variables presented on your spreadsheet (i.e first name, company name, and country)?
    • Will there be any attachments with the e-mail being sent to your clients?
    • What would you like the subject to be? (i.e Product/Company Name - Date)
    • Do you want to pre-fill the body of your text using certain variables from the spreadsheet?
    • Will you be sending CC or BCC to a specific person(s)?
    • Do you have a column containing the list of e-mails for your clients?
    • Would you like to review the e-mail before mailing, or would you like it to send it automatically?
    Draconi

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Automating emails and content from excel via outlook

    Hello Draconi, I was desperate to reply but I had to activate my account which I only just managed, apologies. I would really appreciate your help.

    I have a few questions before I present you with a solution:

    How are the variables presented on your spreadsheet (i.e first name, company name, and country)? Yes exactly like that

    Will there be any attachments with the e-mail being sent to your clients? No

    What would you like the subject to be? (i.e Product/Company Name - Date) Company Name and then some text i.e. Company Name &" Offer"

    Do you want to pre-fill the body of your text using certain variables from the spreadsheet? Yes, i.e. Hello "first names" from "Company name" in "country".

    Will you be sending CC or BCC to a specific person(s)? No

    Do you have a column containing the list of e-mails for your clients? Yes, each client is in a row, Company name, First Name, Country, Email address. It's my client database.

    Would you like to review the e-mail before mailing, or would you like it to send it automatically? No - please just send.

    Looking forward to getting this sorted and again apologies for the delayed response.

    Tom

  4. #4
    Registered User
    Join Date
    04-29-2013
    Location
    Ontario, Canada
    MS-Off Ver
    MS Office 2010
    Posts
    80

    Re: Automating emails and content from excel via outlook

    Hello Tom,

    Here is a solution based on your request. Please bear in mind that a few assumptions have been made in writing your code. Any alterations in the following will cause the code not to function correctly:

    1) Columns are in the following order starting in Row 1:
    1. Company
    2. First Name
    3. Email Address
    4. Country
    5. Product
    6. Offer
    7. Valid Date

    2) The worksheet containing your data must be called "Clients"

    Option Explicit
    
    Public Sub Mailing_List()
        Dim wsClients As Worksheet
        Dim dataArr() As Variant
        Dim company As String
        Dim firstName As String
        Dim email As String
        Dim country As String
        Dim product As String
        Dim offer As String
        Dim validDate As Date
        Dim currDate As Date
        Dim rows As Integer
        Dim i As Integer
        
        currDate = Now()
        Set wsClients = ThisWorkbook.Sheets("Clients")
        dataArr = wsClients.Range("A1").CurrentRegion
        rows = UBound(dataArr, 1)
        
        'Send a generic email to a list of clients from your "Clients" spreadsheet
        For i = 2 To rows
            company = dataArr(i, 1)
            firstName = dataArr(i, 2)
            email = dataArr(i, 3)
            country = dataArr(i, 4)
            product = dataArr(i, 5)
            offer = dataArr(i, 6)
            validDate = dataArr(i, 7)
            Call Mail(company, firstName, email, country, product, offer, validDate, currDate)
        Next i
    End Sub
    
    Private Function Mail(company, firstName, email, country, product, offer, validDate, currDate)
    Application.ScreenUpdating = False
        Dim OutApp As Object
        Dim OutMail As Object
        
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
            
            On Error Resume Next
            With OutMail
                '+---------------------------------------------------------+
                ' You can use the following variables to modify your e-mail:
                '
                ' company       Column A
                ' firstName     Column B
                ' email         Column C
                ' country       Column D
                ' product       Column E
                ' offer         Column F
                ' validDate     Column G
                ' currDate
                '+---------------------------------------------------------+
                .To = email
                .CC = ""
                .BCC = ""
                .Subject = company & " - " & Format(currDate, "mmmm dd, yyyy")
                .HTMLBody = "<font face=calibri color=black>" & _
                            "Hello " & firstName & "," & _
                            "<p>" & "Line 1 *********************************************************************" & "</p>" & _
                            "<p>" & "Line 2 *********************************************************************" & "</p>" & _
                            "<p>" & "Line 3 *********************************************************************" & "</p>" & _
                            "Best Regards," & _
                            "<br>" & "Your Name" & _
                            "<br>" & "Your Title" & _
                            "<br>" & "Your Address" & _
                            "<br>" & "Phone: " & "123456" & _
                            "<br>" & "Cell: " & "123456" & _
                            "<br>" & "Fax: " & "123456" & _
                            "<br>" & "E-mail: " & "<a mailto=Texastom123@excelforum.com>" & "Texastom123@excelforum.com" & "</a>" & _
                            "<br>" & "Website: " & "<a href=www.excelforum.com>" & "http://www.excelforum.com/" & "</a>"
                .Send
            End With
    Application.ScreenUpdating = True
    End Function

  5. #5
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Automating emails and content from excel via outlook

    Clients.xlsxHi Draconi, thank for your reply. I am a little lost though. I created the spreadsheet as best I could and copied the code. I have not used code before though so I hope I did this correctly.

    How will this work in terms of sending the emails?

    What I would like is the option to be selective with who and when I send emails. I use the spreadsheet as a call list and for instance if I cannot reach someone I would like a button or link assigned the their row to send a specific email. Does that make sense?

    Attached is my spreadsheet.

+ 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. MS Outlook Emails from Excel using VBA
    By Dbomber in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2013, 02:23 AM
  2. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  3. [SOLVED] Need help with automating Emails through excel...
    By jrob67806 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-24-2012, 01:53 PM
  4. Send outlook emails with message in cells to individual emails associated with them
    By abinayan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2011, 06:11 AM
  5. Automating Outlook with Excel
    By mppotter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-05-2011, 11:16 AM

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