|
Subject:
|
E-mail using VBA and Outlook
|
|
Posted By:
|
cc16
|
Post Date:
|
2/11/2006 1:56:27 PM
|
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?
|
|
Reply By:
|
Cybersurfer
|
Reply Date:
|
2/12/2006 6:56:05 PM
|
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
|
|
Reply By:
|
Bob Bedell
|
Reply Date:
|
2/12/2006 11:31:36 PM
|
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
|
|
Reply By:
|
Bob Bedell
|
Reply Date:
|
2/13/2006 12:43:30 AM
|
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:
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
|
|
Reply By:
|
cc16
|
Reply Date:
|
2/13/2006 9:47:46 AM
|
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
|
|
Reply By:
|
Bob Bedell
|
Reply Date:
|
2/13/2006 9:07:04 PM
|
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
|
|
Reply By:
|
Bajrang
|
Reply Date:
|
12/4/2006 10:07:24 AM
|
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: 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
|