Experts Exchange connects you with the people and services you need so you can get back to work.
Improve company productivity with a Business Account.Sign Up
Sub Email_Report(ByVal Fname As String)
'sourced from:Automation of out look Mails based on the excel list
'RB: other constants to allow Late Binding*
'Const olFolderInBox As Long = 6
Dim OutApp As Object
Dim oNameSpace As Object
Dim OutMail As Object
'...other code & then...
'check for open Outlook session & open if necessary
'sourced from: Microsoft Office Help - Microsoft Office Discussion - Excel VBA Programming - Access Programming
On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
On Error GoTo 0
'### may need modification
If OutApp Is Nothing Then
Set OutApp = CreateObject("Outlook.Application")
Set oNameSpace = OutApp.GetNamespace("MAPI")
oNameSpace.Logon , , True
'WasOutlookOpenedByCode = True
Set OutMail = OutApp.CreateItem(0)
'Dim OutApp As Object
'Dim OutMail As Object
'Set OutApp = CreateObject("Outlook.Application")
'Set OutMail = OutApp.CreateItem(0)
' On Error Resume Next
' ' Change the mail address and subject in the macro before you run it.
.SentOnBehalfOfName = "PGA Tour"
.To = "Mickelson, Phil; Woods,Tiger"
.CC = "Fowler, Rickie"
.BCC = "Nicklaus, Jack" '
.Subject = "Golf Weekly Update"
.Body = "Blah, Blah Blah"
.Sensitivity = 2
' You can add other files by uncommenting the following line.
' In place of the following statement, you can use ".Display" to
' display the mail.
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.