![]() |
Avoid Security Prompts
I am using Access 2003 to automate an email. The following is my code.
Function sendMessage(strTo As String, strSubject As String, _ strComments As String, Optional AttachmentPath) Dim objOutlookApp As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecipient As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Create the Outlook session. Set objOutlookApp = CreateObject("Outlook.Application") ' Set objOutlookApp = Application ' Create the message. Set objOutlookMsg = objOutlookApp.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. Set objOutlookRecipient = .Recipients.Add(strTo) objOutlookRecipient.Type = olTo ' Set the Subject, Body, and Importance of the message. .Subject = strSubject .Body = strComments & vbCrLf & vbCrLf .Importance = olImportanceHigh 'High importance ' Add attachments to the message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve each Recipient's name For Each objOutlookRecipient In .Recipients objOutlookRecipient.Resolve If Not objOutlookRecipient.Resolve Then objOutlookMsg.Display ' Display any names that can't be resolved End If Next .Send End With Set objOutlookMsg = Nothing Set objOutlookApp = Nothing End Function The email is sent but it prompts 6 times because of security. In a previous comment to another user Sue Mosher indicated that the following line Set objOutlookApp = CreateObject("Outlook.Application") Should be changed to: Set objOutlookApp = Application I have tried this and now I get a Type Mismatch error. Any ideas on how to eliminate the security questions would be appreciated. -- M. Shipp |
Avoid Security Prompts
Replacing objOutlookApp with Application would work if you were working from
Outlook VBA. In case of Access, CreateObject("Outlook.Application") is the only option. See http://outlookcode.com/article.aspx?id=52 Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "SHIPP" wrote in message ... I am using Access 2003 to automate an email. The following is my code. Function sendMessage(strTo As String, strSubject As String, _ strComments As String, Optional AttachmentPath) Dim objOutlookApp As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecipient As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Create the Outlook session. Set objOutlookApp = CreateObject("Outlook.Application") ' Set objOutlookApp = Application ' Create the message. Set objOutlookMsg = objOutlookApp.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. Set objOutlookRecipient = .Recipients.Add(strTo) objOutlookRecipient.Type = olTo ' Set the Subject, Body, and Importance of the message. .Subject = strSubject .Body = strComments & vbCrLf & vbCrLf .Importance = olImportanceHigh 'High importance ' Add attachments to the message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve each Recipient's name For Each objOutlookRecipient In .Recipients objOutlookRecipient.Resolve If Not objOutlookRecipient.Resolve Then objOutlookMsg.Display ' Display any names that can't be resolved End If Next .Send End With Set objOutlookMsg = Nothing Set objOutlookApp = Nothing End Function The email is sent but it prompts 6 times because of security. In a previous comment to another user Sue Mosher indicated that the following line Set objOutlookApp = CreateObject("Outlook.Application") Should be changed to: Set objOutlookApp = Application I have tried this and now I get a Type Mismatch error. Any ideas on how to eliminate the security questions would be appreciated. -- M. Shipp |
Avoid Security Prompts
You can try this:
http://www.download3k.com/Install-Ad...r-Outlook.html "SHIPP" wrote: I am using Access 2003 to automate an email. The following is my code. Function sendMessage(strTo As String, strSubject As String, _ strComments As String, Optional AttachmentPath) Dim objOutlookApp As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecipient As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Create the Outlook session. Set objOutlookApp = CreateObject("Outlook.Application") ' Set objOutlookApp = Application ' Create the message. Set objOutlookMsg = objOutlookApp.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. Set objOutlookRecipient = .Recipients.Add(strTo) objOutlookRecipient.Type = olTo ' Set the Subject, Body, and Importance of the message. .Subject = strSubject .Body = strComments & vbCrLf & vbCrLf .Importance = olImportanceHigh 'High importance ' Add attachments to the message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve each Recipient's name For Each objOutlookRecipient In .Recipients objOutlookRecipient.Resolve If Not objOutlookRecipient.Resolve Then objOutlookMsg.Display ' Display any names that can't be resolved End If Next .Send End With Set objOutlookMsg = Nothing Set objOutlookApp = Nothing End Function The email is sent but it prompts 6 times because of security. In a previous comment to another user Sue Mosher indicated that the following line Set objOutlookApp = CreateObject("Outlook.Application") Should be changed to: Set objOutlookApp = Application I have tried this and now I get a Type Mismatch error. Any ideas on how to eliminate the security questions would be appreciated. -- M. Shipp |
All times are GMT +1. The time now is 11:23 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com