msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Avoid Security Prompts

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program VBA
Author Message
SHIPP



Joined: 12 Aug 2007
Posts: 1

PostPosted: Thu Jan 31, 2008 2:28 pm    Post subject: Avoid Security Prompts Reply with quote

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

Archived from group: microsoft>public>outlook>program_vba
Back to top
View user's profile Send private message
Dmitry Streblechenko



Joined: 12 Aug 2007
Posts: 220

PostPosted: Thu Jan 31, 2008 3:36 pm    Post subject: Re: Avoid Security Prompts Reply with quote

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 @microsoft.com...
>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

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
CDO Outlook security prompt hangs, vb script Mapi Session User is on Windows XP Pro SP2 Office 2003 XP SP2 Using an Outlook 2003 custom form set Session1 = msgbox "Before Logon" on error resume next msgbox "After Logon" msgbox

Outlook security "aprogram is trying to access.." Hi, I am using word vba to automate sending an email with a hyperlink in the body. When I added the coding to include the signature the security setting is triggered. Code is below. Is there a workaround or solution I am missing? Kind regard and many than

How do I stop network password prompts from popping up? Every time outlook processes send/receive I get an Enter Network Password prompt (to a server that I do not recognize).

Outlook 2003 prompts for logon credentials when connected ov I'm having an issue with Outlook 2003 running on WinXP Pro SP2 in an Exchange Server 2003 enviroment. Two people with laptops have the same issue. When they connect using Cisco VPN client (ver 4.8.01.0300) from home, Outlook prompts for username and pas

Security Certificate for OE 6 When I open Outlook Express, version 040803-2158), operating system xp pro sp2, I get the error message --------- “Your server you are connected to is using a security certificate that could not be verified. The certific
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program VBA All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group