 |
Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

February 11th, 2006, 02:56 PM
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
E-mail using VBA and Outlook
I am using a Access mdb to send emails to others at my work. I am doing so my using the following code snippit
Dim stDocName As String
stDocName = "R_ESO"
[All Signatures] = True
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewPreview, , "[display ESO]= forms![f_ESO]![display eso]", acHidden
DoCmd.SendObject acReport, stDocName, acFormatSNP, "Corinne Coates", , , "All signatures recived on ESO", , False
However, I always get a warning message
"A program is trying to automatically send e-mail on your behalf. Do you want to all this?
If this is unexpected, it maybe a virus and you should choose 'No'."
Any one have any ideas how to avoid the warning message?
|

February 12th, 2006, 07:56 PM
|
Registered User
|
|
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Does it say what program is giving you the message? Sounds like an Anti-Virus thing!! How many people are you sending to?
Thanks,
Rich
|

February 13th, 2006, 12:31 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
The messages you are recieving are "normal" behavior imposed by the Outlook security patches when using Access with Outlook automation. To suppress them, download Outlook Redemption from http://www.dimastr.com/redemption/. The link provides extensive discussion of the Redemption object model and how to use Redemption objects in your code.
Bob
|

February 13th, 2006, 01:43 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
I always use Outlook automation for e-mail apps, and don't know if your problem can be solved using DoCmd.SendObject, put if you're using automation this will help you get up to speed using Outlook Redemption.
Youâll download a zip file that contains the Redemption.dll. The .dll is a regular old COM library that you register on your system like any other:
Start --> Run --> Open: regsvr32.exe C:\WINDOWS\SYSTEM32\redemption.dll
Once registered, open the Access References dialog and look for a library named âSafeOutlookLibrary.â If you donât see it, just browse to your WINDOWS\SYSTEM32 forder and select Redemption.dll.
Once you have a reference to the Redemption type library, you can use itâs objects and their members in your code. The .dll is listed in the Object Browser as âRedemptionâ.
The Redemption.SafeMailItem object will replace all the references in your code to the Outlook.MailItem object. This will allow you to bypass the Outlook Model Guard and its blocked properties which cause all the warning messages to display.
Code would look like this:
Code:
Public Function SendMail(strTo As String, _
Optional strCC As String, _
Optional strBCC As String, _
Optional strSubject As String, _
Optional strBody As String) As Boolean
SendMail = False
' Set Outllok app and mailitem object variable.
Dim objOutlookApp As Outlook.Application
Dim objMailItem As Outlook.MailItem
Set objOutlookApp = New Outlook.Application
Set objMailItem = objOutlookApp.CreateItem(olMailItem)
' REDEMPTION OBJECTS: once you have your Outllook MailItem
' object allocated, save it as a Redemption.SafeMailItem
' object.
Set objSafeMail = CreateObject("Redemption.SafeMailItem")
objSafeMail.Item = objMailItem
' Add recipients to your Redemption.SafeMailItem
' recipients collection.
Call objSafeMail.Recipients.Add(strTo)
' Assign subject line and message body, or other
' optinal arguments to your Redemption.SafeMailItem.
objSafeMail.Subject = strSubject
objSafeMail.Body = strBody
' Invoke the Redemption.SafeMailItem Send method.
objSafeMail.Send
'Destroy object variables.
Set objMailItem = Nothing
Set objOutlookApp = Nothing
Set objSafeMail = Nothing
SendMail = True
End Function
E-mails will be sent sans warning messages.
HTH,
Bob
|

February 13th, 2006, 10:47 AM
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Bob thanks for you thoughts. I have one dilemma with this. I have multiple users. They use there own computer system. In the past I have found the using a .dll would have to be installed on all computers. I don't think that is realistic. Any thoughts in regards to this?? Once again thank you so much for you thoughts.
Corinne
|

February 13th, 2006, 10:07 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Corinne,
Really can't add much, unfortunately. There are certainly a number of free tools out there that will let you run regsvr32.exe on a remote machine, but that doesn't sound like an option for you.
There are a few other (fairly arcane sounding) strategies for circumventing Outlook's "Object Model Gaurd", but I've never tried to implement any of them (other than Redemption). Several are listed about halfway down the following link:
http://www.outlookcode.com/d/sec.htm
Would love to know if you have any success with one or the other if you try one.
Bob
|

December 4th, 2006, 11:07 AM
|
Registered User
|
|
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Will RDO REmove the warning: " One programme is trying to access Emaill Address stored in your outlook address book."
Please let me know this.
Thanks in advance.
--------------------------------------------------
Quote:
quote:Originally posted by cc16
I am using a Access mdb to send emails to others at my work. I am doing so my using the following code snippit
Dim stDocName As String
stDocName = "R_ESO"
[All Signatures] = True
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acViewPreview, , "[display ESO]= forms![f_ESO]![display eso]", acHidden
DoCmd.SendObject acReport, stDocName, acFormatSNP, "Corinne Coates", , , "All signatures recived on ESO", , False
However, I always get a warning message
"A program is trying to automatically send e-mail on your behalf. Do you want to all this?
If this is unexpected, it maybe a virus and you should choose 'No'."
Any one have any ideas how to avoid the warning message?
|
Bajrang
|
|
 |