Results 1 to 4 of 4

Send outlook emails with message in cells to individual emails associated with them

Threaded View

  1. #1
    Registered User
    Join Date
    02-11-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    24

    Send outlook emails with message in cells to individual emails associated with them

    Hi everyone,

    Basically I have a data sheet with a list individuals in one column and individual messages in the next and their associated email addresses in another. I have an excel VBA code which sends the whole worksheet as an email attachment to a specific address. Is there a way to modify the code to send individual emails with individual messages via outlook?

    I would basically like the macro to run through each ID and select and copy the data range associated to it as the body of the message and then send it to the corresponding email address. The datarange varies for each ID and I have more than a 1000 of them. I have attached an example sheet with this.

    The code I have currently which sends the whole worksheet as an attachment is as follows:
    Sub email()
    Dim myOutlook As Object
    Dim myMailItem As Object
    Dim FName As String
    Set otlApp = CreateObject("Outlook.Application")
    Set otlNewMail = otlApp.CreateItem(olMailItem)
    FName = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
    With otlNewMail
    .To = "xxx@yyy.com"
    .CC = ""
    .Subject = "Test"
    .Body = "Test"
    .Attachments.Add FName
    .DeferredDeliveryTime = Range("A1")
    .Send
    End With

    Set otlNewMail = Nothing
    Set otlApp = Nothing
    Set otlAttach = Nothing
    Set otlMess = Nothing
    Set otlNSpace = Nothing
    End Sub




    Thanks guys.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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