R
robboll
This VBA sends an outlook email from an application. But requires
human intervention to complete the send.
Note that the code that is commented out is supposed to suppress the
message "A program is trying to automatically send an e-mail on your
behalf. . ." but is failing with a Run-time error '424' Object
required message. I found the code from:
http://www.add-in-express.com/docs/outlook-security-manager-automate.php
Any suggestions on how to deal with the Run-time error?
Private Sub Command0_Click()
Dim db As DAO.Database
Dim retstatus As Long
Dim vTime As Variant
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim theNamespace As Outlook.Namespace
Dim myRecipient As Outlook.Recipient
Set db = CurrentDb()
'OlSecurityManager.ConnectTo OutlookApp ' <----- Fails with Run-
time error '424': Object required
'OlSecurityManager.DisableOOMWarnings = True
'On Error GoTo Finally
Set objOutlook = New Outlook.Application
Set theNamespace = objOutlook.GetNamespace("MAPI")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
objOutlookMsg.To = "(e-mail address removed)"
objOutlookMsg.Subject = "We thought you might want to know!"
objOutlookMsg.Body = "ALARM! ALARM! ALARM! ALARM!"
objOutlookMsg.Importance = olImportanceHigh
objOutlookMsg.Send
Set myRecipient = Nothing
Set objOutlookMsg = Nothing
Set theNamespace = Nothing
Set objOutlook = Nothing
'Finally:
'OlSecurityManager.DisableOOMWarnings = False
End Sub
Thanks for any suggestions!
RBollinger
human intervention to complete the send.
Note that the code that is commented out is supposed to suppress the
message "A program is trying to automatically send an e-mail on your
behalf. . ." but is failing with a Run-time error '424' Object
required message. I found the code from:
http://www.add-in-express.com/docs/outlook-security-manager-automate.php
Any suggestions on how to deal with the Run-time error?
Private Sub Command0_Click()
Dim db As DAO.Database
Dim retstatus As Long
Dim vTime As Variant
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim theNamespace As Outlook.Namespace
Dim myRecipient As Outlook.Recipient
Set db = CurrentDb()
'OlSecurityManager.ConnectTo OutlookApp ' <----- Fails with Run-
time error '424': Object required
'OlSecurityManager.DisableOOMWarnings = True
'On Error GoTo Finally
Set objOutlook = New Outlook.Application
Set theNamespace = objOutlook.GetNamespace("MAPI")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
objOutlookMsg.To = "(e-mail address removed)"
objOutlookMsg.Subject = "We thought you might want to know!"
objOutlookMsg.Body = "ALARM! ALARM! ALARM! ALARM!"
objOutlookMsg.Importance = olImportanceHigh
objOutlookMsg.Send
Set myRecipient = Nothing
Set objOutlookMsg = Nothing
Set theNamespace = Nothing
Set objOutlook = Nothing
'Finally:
'OlSecurityManager.DisableOOMWarnings = False
End Sub
Thanks for any suggestions!
RBollinger