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 / May 2007

Tip: Looking for answers? Try searching our database.

Stop Security Madness

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ivan Grozney - 27 May 2007 04:29 GMT
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 ************************************
Sue Mosher [MVP-Outlook] - 27 May 2007 13:33 GMT
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.

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 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
[quoted text clipped - 64 lines]
> End Sub
> ******** END OUTLOOK CODE ************************************
 
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.