Results 1 to 5 of 5
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Emailing reports automatically

    I've worked this process out in a different thread, but I'm stuck on this one item. When executing the SendTo command.

    Code:
    DoCmd.SendObject acSendReport, "rpt_Report_Letters", acFormatPDF, strEmail, strCC, , Replace(strTitle, "_", " ") & _ 
    " Re: " & strAppl_name, "Dear " & strContactName & ", " & vbNewLine & vbNewLine & "Please see attached report.", False
    I get a dialog box asking permission to send the email out for each recipient.
    Click image for larger version. 

Name:	Allow.JPG 
Views:	18 
Size:	33.3 KB 
ID:	37586

    This defeats the idea of automating this process if the user has to sit around and click each time an email has been prepared. I've been pointed at these security settings in Outlook, but I can't test them since they are locked. Our security guy is reluctant to make changes in these settings.
    Click image for larger version. 

Name:	Outlook Settings.JPG 
Views:	18 
Size:	43.0 KB 
ID:	37587

    My questions are. Is this the culprit in slowing things down or should I look elsewhere? A secondary question is how this process might work with a web based email like G Suite? This is our official email handler. Many of us have stuck with Outlook, but we may be forced to switch over to Google and lose access to Outlook.

    Thanks in advance for your help.

    Paul

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,515
    some Outlook vba has security on it,
    1. set it to NEVER WARN ME, tho this opens you up to viruses.

    2. some older Outlook has it hardwired and you cannot turn off the message box, EXCEPT,
    with an add-in Redemption (google it), this will bypass that nag box.

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I found this here. https://www.outlook-apps.com/disable...urity-warning/

    Code:
                                 Dim outl As outlook.Application
                                 Set outl = New outlook.Application
                                 Dim mi As outlook.MailItem
                                 
                                 Set mi = outl.CreateItem(olMailItem)
                                    mi.body "Dear " & strContactName & ", " & vbNewLine & vbNewLine & "Please see attached report."
                                    mi.Subject = Replace(strTitle, "_", " ") & " Re: " & strAppl_name
                                    mi.To = strEmail
                                    mi.Send
                                 Set mi = Nothing
                                 Set outl = Nothing
    After setting the Outlook Library setting in references I got all the way to mi.Send.
    Click image for larger version. 

Name:	outlook user mi.send 1.JPG 
Views:	18 
Size:	13.7 KB 
ID:	37589

    Close, but no cigar.

    Also, read about redemption. Don't think it is something we could use here. I'll pass it by our security guy though.
    Attached Thumbnails Attached Thumbnails outlook user defined setting.JPG  

  4. #4
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I have another bit of code which produces the same error.

    Code:
      Public Function SendEmail(strTo As String, strSubject As String, strBody As String, bEdit As Boolean, _
                           Optional strBCC As Variant, Optional AttachmentPath As Variant)
        
        'Send Email using late binding to avoid reference issues
           Dim objOutlook As Object
           Dim objOutlookMsg As Object
           Dim objOutlookRecip As Object
           Dim objOutlookAttach As Object
           Dim i As Integer
           Const olMailItem = 0
         
           On Error GoTo ErrorMsgs
         
           Set objOutlook = CreateObject("Outlook.Application")
            
           Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
           With objOutlookMsg
              
              Set objOutlookRecip = .Recipients.Add(strTo)
              objOutlookRecip.Type = 1
         
              If Not IsMissing(strBCC) Then
                Set objOutlookRecip = .Recipients.Add(strBCC)
                objOutlookRecip.Type = 3
              End If
         
              .Subject = strSubject
              .Body = strBody
    Click image for larger version. 

Name:	recipients.add2.JPG 
Views:	15 
Size:	22.9 KB 
ID:	37636

    This can't be a coincidence. Something seems to be missing, though I'm not sure what.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,795
    I get the Outlook warning when my Windows virus protection is out of date even tho programmatic access is set to not warn.

    I have seen code for Gmail.

    Don't see anything wrong with code. It looks like mine. However, instead of Recipients.Add, could build semi-colon separated string of the addresses.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Dynamically Emailing Reports
    By Jessica240 in forum Programming
    Replies: 4
    Last Post: 02-28-2019, 12:21 PM
  2. Emailing Reports
    By nzlowie in forum Reports
    Replies: 7
    Last Post: 01-24-2016, 09:02 AM
  3. Emailing Reports
    By ssworthi in forum Reports
    Replies: 4
    Last Post: 08-25-2015, 04:44 PM
  4. Replies: 3
    Last Post: 12-05-2011, 02:19 PM
  5. Emailing forms or reports
    By dcecil in forum Reports
    Replies: 6
    Last Post: 12-16-2009, 07:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums