+ Reply to Thread
Results 1 to 2 of 2

Send Mail Macro

  1. #1
    Registered User
    Join Date
    08-10-2009
    Location
    Hamilton
    MS-Off Ver
    Excel 2003
    Posts
    7

    Send Mail Macro

    Hello,
    I have created a macro to send an email if certain conditions are met but when I run the macro nothing happens. Can anyone spot the problem? If you need more information about the workbook please ask.

    Kindly, Jordan

    Sub SendEMail()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon

    On Error GoTo cleanup
    For Each cell In Columns("C").Cells.SpecialCells(xlCellTypeConstants)
    If cell.Value Like "?*@?*.?*" And _
    LCase(Cells(cell.Row, "E").Value) = "yes" Then
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .To = cell.Value
    .Subject = "Notice of Renwal: WSIB Certificate of Clearance"
    .Body = "Dear " & Cells(cell.Row, "B").Value _
    & vbNewLine & vbNewLine & _
    "The effective period on your W.S.I.B Certificate of Clearance ends " & Cells(cell.Row, "D").Value _
    & vbNewLine & _
    "Please renew and submit this certificate before this time." & _
    vbNewLine & vbNewLine & _
    "Regards," & _
    vbNewLine & _
    "Kelly Roccha" & _
    vbNewLine & _
    "The Effort Trust Company"


    'You can add files also like this
    '.Attachments.Add ("C:\test.txt")
    .Display
    Application.Wait (Now + TimeValue("0:00:02"))
    Application.SendKeys "%S"
    'Or use Display

    End With
    On Error GoTo 0
    Set OutMail = Nothing
    End If
    Next cell

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Send Mail Macro

    Please edit your post to add CODE tags.
    Entia non sunt multiplicanda sine necessitate

+ 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