+ Reply to Thread
Results 1 to 4 of 4

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

  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 = "[email protected]"
    .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

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Send outlook emails with message in cells to individual emails associated with t

    Put your code in the code tags. It makes it easier to read, not mention it is against forum rules.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

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

    Re: Send outlook emails with message in cells to individual emails associated with t

    Please Login or Register  to view this content.

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

    Re: Send outlook emails with message in cells to individual emails associated with t

    Hi Everyone,

    Just wondering if anyone can help me with this problem. Your help will be greatly appreciated.

    Thanks..

+ Reply to Thread

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