Need to add IF/THEN statement to Macro


Posted by Brian Adkins on March 31, 2000 10:05 AM

On September 27, 1999 at 12:03:42 on this message board, the following post was made explaining how to email a document through a macro using MS Outlook.
-------------------
Sub SendMail()

Dim OL As Object, MailSendItem As Object

Set OL = CreateObject("Outlook.Application")
Set MailSendItem = OL.CreateItem(olMailItem)

With MailSendItem
.Subject = "Test"
.Body = "Testing 1,2,3"
.To = "bob@bob.com; sam@sam.com"
.Attachments.Add ("C:\File.txt")
.Send
End With

End Sub
----------------------------
Now, this code works great but I was wondering, if the user isn't using MS Outlook, what code would have to be added to kickback a message box saying something like, "Sorry, cannot use this macro. Outlook is not installed". I'm assuming it would be some sort of If/Then statement but, I don't know how to write the "IF" part of it.
Anyone able to point me in the right direction?



Posted by Ivan Moala on April 03, 2000 11:36 PM


Not too sure (as I dont use outlook)but one way to do this;

You could try the following as one way


Dim OL As Object, MailSendItem As Object
Dim olMailItem

On Error Resume Next
Set OL = CreateObject("Outlookexpress.Application")
If Err.Number = 429 Then GoTo ErrH
Set MailSendItem = OL.CreateItem(olMailItem)

With MailSendItem
.Subject = "Test"
.Body = "Testing 1,2,3"
.To = "bob@bob.com; sam@sam.com"
.Attachments.Add ("C:\File.txt")
.Send
End With

Exit Sub
ErrH:
MsgBox "Component not installed!"

End Sub


I'm not 100% sure but the component you are after is the
Outlook 98 type library.


Ivan