Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / March 2007

Tip: Looking for answers? Try searching our database.

code to bypass security

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michelle Hanan - 27 Mar 2007 22:32 GMT
I am running a macro in excel that email merges through Outlook 07. I would
like to find code to avoid getting the "a program is trying to access email
address information stored in Outlook" message. Is there such?
Dmitry Streblechenko - 27 Mar 2007 22:53 GMT
See http://www.outlookcode.com/d/sec.htm

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

>I am running a macro in excel that email merges through Outlook 07. I would
>like to find code to avoid getting the "a program is trying to access email
>address information stored in Outlook" message. Is there such?
Michelle Hanan - 28 Mar 2007 00:57 GMT
Ok, so I'm a little confused. Which code do I use and where should I insert
it into my macro?
Here's the email merge portion of my macro:

myDoc.MailMerge.MainDocumentType = wdEMail
   myDoc.MailMerge.OpenDataSource Name:= _
      "\\powervault2\home_pl\common\Email\Referals.xls", _
       ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
       AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
       WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
       Format:=wdOpenFormatAuto, Connection:= _
       "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=\\powervault2\home_pl\common\Email\Referals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
       , SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
       wdMergeSubTypeAccess
   With myDoc.MailMerge
   .Destination = wdSendToEmail
   .MailAddressFieldName = "Address"
   .MailSubject = "Referals"
   .MailAsAttachment = True
       .SuppressBlankLines = True
       With .DataSource
           .FirstRecord = wdDefaultFirstRecord
           .LastRecord = wdDefaultLastRecord
       End With
       .Execute Pause:=False
     End With
     myDoc.Close wdDoNotSaveChanges
End Sub

> See http://www.outlookcode.com/d/sec.htm
>
[quoted text clipped - 7 lines]
>>access email address information stored in Outlook" message. Is there
>>such?
Sue Mosher [MVP-Outlook] - 28 Mar 2007 13:34 GMT
Your options are limited because you are not technically doing Outlook automation at all. If you want to stick with that code, you'd have to use one of the tools on the page Dmitry suggested that suppresses the prompts. If, on the other hand, you want the prompts to disappear completely, with Outlook 2007 and an up-to-date anti-virus application running on your system, you will get no prompts if you use the Outlook object model directly in your code.

It's up to you now to decide whether it's worth the effort to rewrite the code to use the Outlook object model or use one of the utilities on the page Dmitry suggested.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

> Ok, so I'm a little confused. Which code do I use and where should I insert
> it into my macro?
[quoted text clipped - 32 lines]
>
>> See http://www.outlookcode.com/d/sec.htm

>>>I am running a macro in excel that email merges through Outlook 07. I
>>>would like to find code to avoid getting the "a program is trying to
>>>access email address information stored in Outlook" message. Is there
>>>such?
Michelle Hanan - 29 Mar 2007 19:54 GMT
I think the easiest way would be to insert the code because I'm not doing
the outlook automation. Although I am still confused where I would put that
particular line of code: objMailItem.To = webmaster@outlookcode.com to
suppress the security prompt.

Here is my whole macro that I am trying to run.....

Sub Ecology()
'This first macro opens word for the rest of the macros. It also merges data
from Referals.xls, worksheet one, into different merge fields on the
document stated in the macro.
Dim wdApp As Object
Dim myDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
Set myDoc = Word.Documents.Open("\\powervault2\home_pl\common\Email\Referal
Agency - Ecology.doc")
   myDoc.MailMerge.MainDocumentType = wdEMail
   myDoc.MailMerge.OpenDataSource Name:= _
      "\\powervault2\home_pl\common\Email\Referals.xls", _
       ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
       AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
       WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
       Format:=wdOpenFormatAuto, Connection:= _
       "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=\\powervault2\home_pl\common\Email\Referals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
       , SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
       wdMergeSubTypeAccess
   With myDoc.MailMerge
   .Destination = wdSendToEmail
   .MailAddressFieldName = "Address"
   .MailSubject = "Referals"
   .MailAsAttachment = True
       .SuppressBlankLines = True
       With .DataSource
           .FirstRecord = wdDefaultFirstRecord
           .LastRecord = wdDefaultLastRecord
       End With
       .Execute Pause:=False
     End With
     myDoc.Close wdDoNotSaveChanges
End Sub

Your options are limited because you are not technically doing Outlook
automation at all. If you want to stick with that code, you'd have to use
one of the tools on the page Dmitry suggested that suppresses the prompts.
If, on the other hand, you want the prompts to disappear completely, with
Outlook 2007 and an up-to-date anti-virus application running on your
system, you will get no prompts if you use the Outlook object model directly
in your code.

It's up to you now to decide whether it's worth the effort to rewrite the
code to use the Outlook object model or use one of the utilities on the page
Dmitry suggested.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Ok, so I'm a little confused. Which code do I use and where should I
> insert
[quoted text clipped - 35 lines]
>
>> See http://www.outlookcode.com/d/sec.htm

>>>I am running a macro in excel that email merges through Outlook 07. I
>>>would like to find code to avoid getting the "a program is trying to
>>>access email address information stored in Outlook" message. Is there
>>>such?
Sue Mosher [MVP-Outlook] - 29 Mar 2007 20:22 GMT
Setting the value of objMailItem.To would never raise a security prompt. This is not a simple "insert the code" project. You would have to complete rewrite the code in two phases:

1) Perform a merge to create and save individual Word documents

2) For each document created in the merge, create and send an individual Outlook MailItem (message). The MailItem.Send method would trigger a security prompt unless the code is running in Outlook or you use Redemption or one of the other approaches listed on the page suggested.
Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

>I think the easiest way would be to insert the code because I'm not doing
> the outlook automation. Although I am still confused where I would put that
[quoted text clipped - 99 lines]
>>>>access email address information stored in Outlook" message. Is there
>>>>such?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.