Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm sending an e-mail from Access w

Status
Not open for further replies.

AllenRitch

Technical User
May 20, 2003
52
US
I'm sending an e-mail from Access with the following code:

Dim outLookApp As Outlook.Application
Dim eMailItem As Outlook.MailItem
Dim strTo As Outlook.Recipient
Dim strCc As Outlook.Recipient
Dim strRecipient As String, strRecipient2 As String

strSubject = "Subject"
strBody = "Message"
Set outLookApp = New Outlook.Application
Set eMailItem = outLookApp.CreateItem(olMailItem)
Set strTo = eMailItem.Recipients.Add(strRecipient)
Set strCc = eMailItem.Recipients.Add(strRecipient2)
strCc.Type = olCC
With eMailItem
.Subject = strSubject
.Body = strBody
End With
eMailItem.Display {will change to .Send once live}

The code above works fine so long as Outlook is already open. However, if I run it while Outlook is closed, I recieve error message. I've also tried a few variations of the Set statement (which also worked when Outlook was open).

So is there anyway I can have the program look to see if Outlook is open or not? If it is open I'll proceed with above. If not, I'll use the Shell function to open Outlook first.

Thanks



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top