Hi there. I'm a complete noob when it comes to VBA. I have some code that I got online to send an email using Outlook through Access 2010. The code works by displaying an Outlook message window, but the message sits in the outbox until I open Outlook. Is there anyway to keep Outlook open long enough for the message to send. The reason I am asking is because this database will be used in work and I cannot guarantee that the guys will open Outlook to complete the message sending process.
Here is what I have so far. I have not added any content to the message yet as I am still testing:
Here is what I have so far. I have not added any content to the message yet as I am still testing:
Code:
Private Sub Re_Order_Click() Dim OutApp As Object Dim OutMail As Object Dim blnOLOpen As Boolean On Error Resume Next Set OutApp = GetObject(, "Outlook.Application") blnOLOpen = True If OutApp Is Nothing Then Set OutApp = CreateObject("Outlook.Application") blnOLOpen = False End If On Error GoTo 0 Set OutMail = OutApp.CreateItem(olMailItem) With OutMail .To = "email address" .Subject = "This is the Subject line" .Body = "testing" .Display '.Send - I have tried this without .display and does not work either End With End Sub
Comment