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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email problem using Access VBA (Outlook)

Status
Not open for further replies.

danvzla

Programmer
Jan 16, 2004
28
FI
Hi all

I already post this Q on a different thread but because theinitial subjet was for a different task I've not got an answer. This code works, but it only send the msg when Outlook is open. How can I do to send it still if outlook is close? Is there a way of knowing if outlook is running?


Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

'***creates and sends email
With objEmail
.To = DistributionList
.Subject = SubjectText
.Body = BodyText

If EditMsg = True Then

.Display

Else
.Save
.Send 'sends the email in Outlook. Change to DISPLAY if you want to be able to modify or see what you have created before sending the email

End If

End With

'**closes outlook
'objOutlook.Quit
Set objEmail = Nothing


Thanks

Dan
 
Is there a way of knowing if outlook is running
Use the GetObject function and test if an error is raised.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top