+ Reply to Thread
Results 1 to 2 of 2

Sending Email from VBA - selecting correct email address issue

  1. #1
    Registered User
    Join Date
    07-21-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    6

    Sending Email from VBA - selecting correct email address issue

    Hi, I'm quite new to VBA, but have managed to put together code in a schedule that sends an email to the task owner and co-owner if a task is overdue. The email addresses are stored in the worksheet. It works ok, except that I've clearly not set something up correctly as at the moment the emails are all going to the addresses in F4 and H4 (see below). I just can't work out how I should change this so that it loops through each row and, if column U shows 'Overdue', an email is sent to the address in columns F and H. Can anyone help please? Thanks, Rachel



    Sub Send_UK_Overdue()

    Dim Mail_Object, Mail_Single As Variant
    Dim rng As Range
    Dim rngFound As Range

    Set rng = Range("U:U")

    Set rngFound = rng.Find("Overdue")

    nameEmail = Range("F4").Value
    ccEmail = Range("H4").Value

    If rngFound = rng.Find("Overdue") Then

    Email_Subject = "Overdue Task"
    Email_Send_From = "EMAIL ADDRESS"
    Email_Send_To = nameEmail
    Email_Cc = ccEmail
    Email_Body = "You have an task overdue by two weeks or more."

    On Error GoTo debugs
    Set Mail_Object = CreateObject("Outlook.Application")
    Set Mail_Single = Mail_Object.CreateItem(0)

    With Mail_Single
    .Subject = Email_Subject
    .To = Email_Send_To
    .cc = Email_Cc
    .BCC = Email_Bcc
    .Body = Email_Body
    .send
    End With

    debugs:
    If Err.Description <> "" Then MsgBox Err.Description

    End If

    End Sub

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Sending Email from VBA - selecting correct email address issue

    Not tested but maybe something like this...

    Please Login or Register  to view this content.
    Martin

+ 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. Macro sending email from different email address.
    By learningslowly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2014, 03:24 PM
  2. automation/macro for sending email to multiple email address
    By saurabhlotankar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2013, 12:13 PM
  3. Sending Email with email address in cell 22
    By albert28 in forum Excel General
    Replies: 1
    Last Post: 01-19-2012, 11:24 AM
  4. Sending Spreadsheet To Email Address
    By IanD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2009, 08:10 AM

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