Hello all,
Can anyone show me a way to test if Outlook is open. If it is not I want to open it and send my message. If it is with the code I have I can start an object and send my message. The code I have only works if outlook is already open. Currently I only know how to open up a new application using shell.
Dim objOutLook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As String
Set objOutLook = CreateObject("Outlook.Application"
Set objOutlookMsg = objOutLook.CreateItem(olMailItem)
objOutlookAttach = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With objOutlookMsg
.Recipients.Add "Whoever@anywhere.com"
.CC = msgCC
.Subject = "Just a test!"
.Body = msgBody
.Attachments.Add objOutlookAttach
If ImportanceHigh = False Then
.Importance = olImportanceNormal
Else
.Importance = olImportanceHigh
End If
'Resolving the message removes all invalid e-mail address, this will handle up to 5 invalid email addresses
Dim i As Integer
i = 1
Do While i < 5
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookRecip.Delete
End If
Next
i = i + 1
Loop
If SendNow = False Then
.Display (False)
ElseIf SendNow = True Then
.Send
End If
End With
Set objOutlookMsg = Nothing
Set objOutLook = Nothing
Any help would be appreciated!
Dugger
Can anyone show me a way to test if Outlook is open. If it is not I want to open it and send my message. If it is with the code I have I can start an object and send my message. The code I have only works if outlook is already open. Currently I only know how to open up a new application using shell.
Dim objOutLook As Object
Dim objOutlookMsg As Object
Dim objOutlookRecip As Object
Dim objOutlookAttach As String
Set objOutLook = CreateObject("Outlook.Application"
Set objOutlookMsg = objOutLook.CreateItem(olMailItem)
objOutlookAttach = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With objOutlookMsg
.Recipients.Add "Whoever@anywhere.com"
.CC = msgCC
.Subject = "Just a test!"
.Body = msgBody
.Attachments.Add objOutlookAttach
If ImportanceHigh = False Then
.Importance = olImportanceNormal
Else
.Importance = olImportanceHigh
End If
'Resolving the message removes all invalid e-mail address, this will handle up to 5 invalid email addresses
Dim i As Integer
i = 1
Do While i < 5
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookRecip.Delete
End If
Next
i = i + 1
Loop
If SendNow = False Then
.Display (False)
ElseIf SendNow = True Then
.Send
End If
End With
Set objOutlookMsg = Nothing
Set objOutLook = Nothing
Any help would be appreciated!
Dugger