Question Access emails without outlook warning

humph

Registered User.
Local time
Today, 11:49
Joined
Sep 7, 2006
Messages
69
Access emails without outlook warning - solved

Hi - I am developing an application which is going to be packaged into a run version in Access 2010 / 2013 and I need to send emails containing invoices to a lot of clients.

How can I send the emails without the security warning or alternatively some method to have the security message come up once rather than for each email.

I want to do this from within Access if at all possible.

Has anyone used Outlook redemption for this?
Any pointers much appreciated
:banghead::banghead::banghead::banghead::banghead:
 
Last edited:
Found the solution below - it seems to have been written with Excel in mind but it works perfectly in Access.

The only problem seems to be that any attachments must be from outside the database.

My apologies to the person that posted the code - I accidently closed the forum and lost the thread that provided it.

:D:D:D



Based on Ron de Bruin's code of Example 1
' from link http://www.rondebruin.nl/mail/folder2/mail1.htm
Sub Mail_workbook_Outlook()

Dim OutApp As Object, OutMail As Object
Dim cmd As String, t As Single

' Try to GetObject
On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
If Err Then
' --> Simulate CreateObject("Outlook.Application")
cmd = """" & Application.Path & "\OUTLOOK.EXE"""
Shell cmd, vbHide
t = Timer + 10 ' timeout = 10 seconds max
While OutApp Is Nothing And Timer < t
Set OutApp = GetObject(, "Outlook.Application")
Wend
' <-- End of simulation
End If
Set OutMail = OutApp.CreateItem(0)

With OutMail
.To = "Please@DoNotMail.it"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .Send
End With
On Error GoTo 0

Set OutMail = Nothing
'OutApp.Quit
Set OutApp = Nothing

End Sub
 
I doubt very much that this is a verbatim copy from de Bruin, because the entire:

Code:
' Try to GetObject
  On Error Resume Next
  Set OutApp = GetObject(, "Outlook.Application")
  If Err Then
    ' --> Simulate CreateObject("Outlook.Application")
    cmd = """" & Application.Path & "\OUTLOOK.EXE"""
    Shell cmd, vbHide
    t = Timer + 10  ' timeout = 10 seconds max
    While OutApp Is Nothing And Timer < t
      Set OutApp = GetObject(, "Outlook.Application")
    Wend
    ' <-- End of simulation
  End If
can be replaced by:

Code:
Set OutApp = CreateObject("Outlook.Application")
 
The problem with sending through Outlook is that the Outbox is updated. You could consider SMTP as an alternative.

Simon
 

Users who are viewing this thread

Back
Top Bottom