+ Reply to Thread
Results 1 to 3 of 3

Send Mail Macro

Hybrid View

jregan Send Mail Macro 08-24-2010, 10:08 AM
Dulanic Re: Send Mail Macro 08-24-2010, 11:17 AM
wotadude Re: Send Mail Macro 08-25-2010, 07:34 PM
  1. #1
    Registered User
    Join Date
    08-10-2009
    Location
    Hamilton
    MS-Off Ver
    Excel 2003
    Posts
    7

    Send Mail Macro

    Hello there,

    I would like to create a macro for my workbook which sends a mail message to addresses in Column C (range C2:C100) when the value in column F (range f2:f100) reads "Yes". Does such a thing exist?

    Your help is graciously appreciated.

    Jordan

  2. #2
    Forum Contributor
    Join Date
    12-03-2009
    Location
    Providence RI
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    260

    Re: Send Mail Macro

    I believe you need to be more specific. What are you wanting to send? One of the cells? The worksheet? The workbook? Just a pre-filled email?

  3. #3
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: Send Mail Macro

    This may get you started
    Private Sub Worksheet_Change(ByVal Target As Range)
        ' If the value a cell within range F2 to F100 is changed to Yes
        ' then send an email alert
        Dim OutApp As Object
        Dim OutMail As Object
        Dim sBody As String
        Dim sTo As String
        If Not Intersect(Target, Range("f2:f100")) Is Nothing Then
            With Target
                If .Value = "Yes" And .Count = 1 Then
                    sBody = "The status of the record in row " & .Row & _
                            " has been updated to ""Yes"" by " & Environ("username")
                    sTo = Cells(.Row, "C").Value
                    Set OutApp = CreateObject("Outlook.Application")
                    OutApp.Session.Logon
                    Set OutMail = OutApp.CreateItem(0)
                    On Error Resume Next
                    With OutMail
                        .to = sTo
                        .Subject = "Status Update"
                        .Body = sBody
                        .display ' to send automatically change .display to .send
                    End With
                    On Error GoTo 0
                    Set OutMail = Nothing
                    Set OutApp = Nothing
                End If
            End With
        End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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