Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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
 
Old June 8th, 2006, 08:13 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default E-mailing reports

Hi All
I am e-mailing reports using the following code
DoCmd.SendObject acSendReport, "Rpthrs", acFormatSNP, "", "", "", " ", " "
Is it possible to generate an e-mail with two reports.At present I can only generate one at a time.
Thanks


Brendan Bartley
__________________
Brendan Bartley
 
Old June 9th, 2006, 07:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Currently there is no way you can attach more than one report to an e-mail.

The closest thing you can get to is call the SendObject method twice. It will generate two independent e-mails with attachments. If your e-mail program is flexible enough, you can drag and drop attachment 2 next to the other e-mail's attachment 1 and then cancel e-mail 2.

Note, you do not have to place "" or " " in your SendObject statement. Just don't put anything.

    DoCmd.SendObject acSendReport, "Rpthrs", acFormatSNP

is enough. For methods that involve something at the end, e.g.

    DoCmd.OpenReport "Rpthrs", acPreview, , strCriteria

notice that you only have to include the comma as a placeholder but you don't need "" or " ".


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old June 9th, 2006, 08:28 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all the help

Brendan Bartley
 
Old June 12th, 2006, 12:26 PM
Registered User
 
Join Date: Jun 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scubasteve
Default

You can if you create the files and save to disk and then create code to email and attach documents. I attached 20 documents to an email all generated and sent through Access. I have some code around some place if I can find it.

Neil
 
Old June 13th, 2006, 09:43 AM
Registered User
 
Join Date: Jun 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scubasteve
Default

I believe I found the right one. This should attach all files in a directory to an email.


Function Email12MthReports()

    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
    Dim AttachmentPath As String
    Dim fso, f, fc, file

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder("N:\Exports\" & MonthName(Month(Form_frmACLSRptsMTDYTD!MthBegDt)) & " - " & Year(Form_frmACLSRptsMTDYTD!MthBegDt) & "\12-Month\")
    Set fc = f.files

    On Error Resume Next
    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")

    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
        ' Add the To recipient(s) to the message.
        Set objOutlookRecip = .Recipients.Add("Neil Shefler;Valeria Audivert")
        objOutlookRecip.Type = olTo

       ' Set the Subject, Body, and Importance of the message.
       .Subject = "Branch 12-Month PnL Reports"
       .Body = "Attached are the 12-Month PnL report by branch." & vbCrLf & vbCrLf
       .Importance = olImportanceNormal

       ' Loop through files to attach
       For Each file In fc
            Let AttachmentPath = file
            ' Add attachments to the message.
            If Not IsMissing(AttachmentPath) Then
               Set objOutlookAttach = .Attachments.Add(AttachmentPath)
            End If
       Next
       rst.Close

       ' Resolve each Recipient's name.
       For Each objOutlookRecip In .Recipients
           objOutlookRecip.Resolve
           If Not objOutlookRecip.Resolve Then
               objOutlookMsg.Display
           End If
       Next
       .Send

    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing

End Function

Neil
 
Old June 26th, 2006, 01:37 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

scubasteve,

The code above works for me if I do not use more than one email addy as you posted..

Set objOutlookRecip = .Recipients.Add("Neil Shefler;Valeria Audivert")

Using more than one gives me problems in the resolve portion of the code

' Resolve each Recipient's name.
     For Each objOutlookRecip In .Recipients
         objOutlookRecip.Resolve
         If Not objOutlookRecip.Resolve Then
             objOutlookMsg.Display
         End If
     Next
And shows me a message box "Can't contact LDAP Directory Server (81)" after a few minutes.

Anyone having any ideas on how I can resolve this issue?

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
About Mailing List ssomchai BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 May 5th, 2008 10:05 PM
mailing manish_partey ASP.NET 1.0 and 1.1 Professional 1 April 25th, 2007 08:20 AM
Mailing prashanth_kumarbv Classic ASP Basics 2 October 27th, 2006 08:40 PM
E-mailing reports Dharam80 Access 12 August 31st, 2005 02:05 PM
SMTP not mailing...help! c_bananas .NET Web Services 5 November 17th, 2003 01:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.