Stop Security Madness

I

Ivan Grozney

I am trying it get the following code in Access to call Outlook and send a
bunch of emails. Each one is different for each of the recipients and it can
be for one to 50 or even more. I would like to bypass the Outlook security,
preferably not using on of the 3rd party products like ClickYes.

I am using Outlook and Access 2003.

I have looked at other posts and at http://www.outlookcode.com/d/sec.htm
but I just don't get it.

TIA

Vanya

******* Start Record Set Code **************************************
Private Sub cmdMailTotalPoints_Click()
On Error GoTo Err_CmdMailTotalPoints_Click
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT <stuff> FROM <mytable>")
Set qdf = dbs.QueryDefs("<myQuery>")
BaseSQL = qdf.SQL
strFrom = "<whofrom>"
strSubject = "<Subject>"
strBodyEnd = vbCrLf & _
"If you have any questions..." & vbCrLf & _
vbCrLf & _
"Thank you ..."
With rst
Do Until .EOF
strSQL = Left(BaseSQL, Len(BaseSQL) - 1)
qdf.SQL = strSQL
strEmail = !HWorkEmail
strBodyStart = "" & !FirstName & ", " & vbCrLf & _
vbCrLf & _
"Your current account info is..." & vbCrLf & _
Stuff... vbCrLf
strBody = strBodyStart & strBodyEnd
' Call the Mass Mailing Routine
Call MassMail(strFrom, strBody, strEmail, strSubject)
.MoveNext
Loop
.Close
End With
qdf.SQL = BaseSQL
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing
******* End Record Set Code **************************************

******** START OUTLOOK CODE ************************************
Private Sub MassMail(strFrom As Variant, strBody As Variant, strEmail As
Variant, strSubject As Variant)
Dim olApp As Outlook.Application
Dim olMsg As MailItem
Set olApp = CreateObject("Outlook.Application")
Set olMsg = outApp.CreateItem(olMailItem)
With olMsg
.To = strEmail
.SentOnBehalfOfName = strFrom
.Subject = "TEST TEST Please Delete TEST"
.SenderEmailAddress = strFrom
.Body = strBody
.Send
End With
Set olApp = Nothing
Set olMsg = Nothing
End Sub
******** END OUTLOOK CODE ************************************
 
S

Sue Mosher [MVP-Outlook]

What is it that you don't "get"? External automation of Outlook 2003 is subject to security prompts. The page you cited lists all the possible ways to avoid the security prompts. If you don't want to use something like ClickYes, you're not in an environment where the Exchange administrator will loosen security for you, and you want to stick to Access VBA, then rewriting the code using Redemption is the best available solution for you.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top