Outlook Security Message

  • Thread starter Thread starter Brendan MAther
  • Start date Start date
B

Brendan MAther

I'm trying to send emails to various contacts that come up in a form based
on a query, however, when I click on the 'email' button it prompts me that
"A Program is trying to access e-mail addresses you have stored in Outlook.
Do you want to allow this?

If this is unexpected, ......."

I would rather this didn't show up after clicking the "email" button, is
there some code that I can input here to disable this message?

This is the code I'm using on the button click:

Private Sub Emailcommand_Click()
Dim oApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone
Set oApp = New Outlook.Application

Set objNewMail = oApp.CreateItem(olMailItem)
With objNewMail
rs.MoveFirst
Do While Not rs.EOF
If Len(Trim(rs!email)) > 0 Then
Set objOutlookRecip = .Recipients.Add(rs!email)
objOutlookRecip.Type = olTo
End If
rs.MoveNext
Loop
'.Subject = Me.txtSubject
'.Body = "Your text message here."
'.Attachments "Filename.xxx"
'.Save
.Display
End With

End Sub

Thanks,

Brendan MAther
 
Brendan,

This is to do with Outlook's security features. The only ways I have
heard of that people have used to handle this type of problem:
1. Revert to an earlier version of Outlook
2. http://www.express-soft.com/mailmate/clickyes.html

There may be other ways of handling it, in which case you may be more
likely to get a good answer if you try posting to
microsoft.public.outlook newsgroup.

- Steve Schapel, Microsoft Access MVP
 
I've created a work around to this problem by using a temporary email
variable that holds email addresses until the last one has been added, then
adds that as one string to the "To" box in the email window.
Seems to avoid the warning so far.

the code I use looks like this:

Private Sub emailButton2_Click()
Dim oApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim rs As DAO.Recordset
Dim TempEmail

Set rs = Me.RecordsetClone
Set oApp = New Outlook.Application
Set objNewMail = oApp.CreateItem(olMailItem)


rs.MoveFirst
Do While Not rs.EOF
If IsNull(rs!email) Then
rs.MoveNext
Else
TempEmail = TempEmail + rs!email + "; "
rs.MoveNext
End If
Loop

With objNewMail
.To = TempEmail
'.Subject = Me.txtSubject
'.Body = "Your text message here."
'.Attachments "Filename.xxx"
.Display
'.Save
'.SendEmail = False
End With
End Sub

Brendan
 
Back
Top