Results 1 to 7 of 7

Thread: Convert VBA Code Designed for Windows To Run On A Mac

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Site Admin VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,496
    Location
    Here is your code
    Sub Send_Email()
        Dim OutApp as Object, OutMail As Object
        Dim lLastRow as Long, lRow as Long
        Dim sSendTo as String, sSendCC as String, sSendBCC as String
        Dim sSubject as String, sTemp as String
        On Error goto errHandler
        SetOutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        ' Change the following as needed
        sSendTo = "Michael@lafamilialf.com"
        sSendCC = "mrempel@excel-bytes.Com"
        sSubject = "Project Past Due!"
        lLastRow = Cells(Rows.Count,1).End(xlUp).Row
        For lRow = 2 to lLastRow
            If Cells(lRow ,4)<>"Completed" Then
                If Cells(lRow,2)<=Date Then
                    SetOutMail = OutApp.CreateItem(0)
                    ' On Error Resume Next
                    With OutMail
                         .To = sSendTo
                         If sSendCC > " " Then .CC = sSendCC
                         If sSendBCC > " " Then .BCC = sSendBCC
                         .Subject = sSubject
                         sTemp ="Hello!" & vbCrLf & vbCrLf
                         sTemp = sTemp & "The due date has passed fro this project: " & vbCrLf & vbCrLf
                        ' Assumes project name is in Column B
                        sTemp & " " & Cells(lRow,1) & vbCrLf & vbCrLf
                        sTemp = sTemp & "Please take appropriate action." & vbCrLf & vbCrLf
                        s temp = sTemp & "Thank You!" & vbCrLf
                        .Body = sTemp
                        ' Change the following to.Send if you want to send the message without reviewing first .Send
                        .Send
                    End With
                    Set OutMail = Nothing
                    Cells(lRow,6) = "E-mail sent on: " & Now()
               End if
           End If
        Next lRow
        exitHere:
        Set OutApp = Nothing
        Exit Sub
        errHandler:
        MsgBox "Error " & Err.Number & ": " & Err.Description
        Resume exitHere
    End Sub
    Last edited by Aussiebear; 01-10-2025 at 04:13 AM.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •