![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modify Code Using Outlook Redemption to bypass security prompts | mhgreene | Outlook and VBA | 5 | October 3rd 07 11:50 PM |
Avoid outlook security warning message. | ashish taralekar | Outlook - Using Forms | 1 | April 11th 07 06:06 PM |
get reed of security prompts | Kan Kan | Outlook - General Queries | 7 | August 28th 06 03:27 PM |
Another question about security prompts | ML | Outlook - Using Forms | 1 | March 22nd 06 05:45 PM |
Is there a way to avoid needing to "allow" outlook security to send email? | Mr . . | Outlook - Using Forms | 1 | January 28th 06 03:18 PM |