Results 1 to 12 of 12
  1. #1
    maddaddy is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    5

    rename report and email

    Is there a way to change the name of the report before emailing?

    I want the attachment to have certain information in it, specific to the report. (e.g. report number and name, which comes from the table)

    here's what I have so far...

    Private Sub Command47_Click()


    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport "tasker report", acViewPreview, , "[tasker number] = " & [tasker number]
    DoCmd.SendObject acSendReport, "tasker report", acFormatPDF
    End Sub

    Thank you ahead of time
    Last edited by maddaddy; 09-20-2010 at 11:01 PM.

  2. #2
    maddaddy is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    5
    tap tap. ?? this thing on?

  3. #3
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Are you wanting to change the name of the attachment?

    What is the current name?

    PS: Not many people have Access 2007 0r 2010.

  4. #4
    maddaddy is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    5
    Quote Originally Posted by HiTechCoach View Post
    Are you wanting to change the name of the attachment?

    What is the current name?

    PS: Not many people have Access 2007 0r 2010.
    the current name is called "tasker report"

    If I save it manually using "Save As" then I can save it with what ever name I want. then when I send it via email, it has the proper name.

    Now to do all that with one button

  5. #5
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    I do not know it it is possible using the SendObject command.

    It can be done using automation with Outlook or SMTP/CDO. I use SMTP/CDO a lot.

  6. #6
    maddaddy is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    5
    do tell??

  7. #7
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by maddaddy View Post
    do tell??

    Do you want to use Outlook automation or SMTP?

  8. #8
    maddaddy is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    5
    Quote Originally Posted by HiTechCoach View Post
    Do you want to use Outlook automation or SMTP?
    I use outlook automation.

  9. #9
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702

  10. #10
    drobizzle is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    5
    I have the same problem. I need to rename the attachment before emailing.

  11. #11
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by drobizzle View Post
    I have the same problem. I need to rename the attachment before emailing.
    First you will need to save the file.

    You can use FSO or the vba command Name to rename the file

    Then attach the file to an email.


    From the help file:

    Name Statement Example

    This example uses the Name statement to rename a file. For purposes of this example, assume that the directories or folders that are specified already exist. On the Macintosh, “HD:” is the default drive name and portions of the pathname are separated by colons instead of backslashes.
    Dim OldName, NewName OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names. Name OldName As NewName ' Rename file. OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE" Name OldName As NewName ' Move and rename file.

  12. #12
    crxftw is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    30
    That's what I use. It saves my reports to specific folder and creates new folder if it doesn't exist.

    Code:
        Sub SendMessage(Optional AttachmentPath)
              Dim objOutlook As Outlook.Application
              Dim objOutlookMsg As Outlook.MailItem
              Dim objOutlookRecip As Outlook.Recipient
              Dim objOutlookAttach As Outlook.Attachment
              Dim mystr As String
              Dim myCurrentDir As String
            
                myCurrentDir = CurrentProject.Path & "\" 'Directory of current database
                
              Set objOutlook = CreateObject("Outlook.Application")
              Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    
              With objOutlookMsg
    
                 .To = Nz(<your email field here>, "")
                 .Subject = "Subject"             
                 .BodyFormat = olFormatHTML           
                   
                    mystr = "HTML formatted body message"
            
                 .HTMLBody = mystr
    
                 If Not IsMissing(AttachmentPath) Then 'Add attatchment
                     Set objOutlookAttach = .Attachments.Add(AttachmentPath)
                 End If
    
                 .Display 'Display the whole thing in Outlook
    
              End With
              Set objOutlook = Nothing
          End Sub
    Now button to call the send function

    Code:
    Private Sub cmdEmail_Click()
    
    If Not IsNull(<your email field here>) Then
    
        Dim myCurrentDir As String
        Dim myInvoiceDir As String
        Dim myInvoiceOutput As String
    
        myCurrentDir = CurrentProject.Path & "\"
        myInvoiceDir = myCurrentDir & "<your desired directory>" & "\" & "<your desired sub directory>" & "\"
        myInvoiceOutput = myInvoiceDir & <name of your report> & ".pdf"
        
    
        If Len(Dir(myInvoiceDir, vbDirectory)) = 0 Then
            MkDir myInvoiceDir
        Else
            DoCmd.OutputTo acOutputReport, <your report name here>, acFormatPDF, myInvoiceOutput, , , , acExportQualityPrint
            SendMessage, myInvoiceOutput 'Call the SendMessage function with attatchment path
        End If
    
    Else
        MsgBox ("No E-mail address available for this client")
    
    End If
    
    End Sub

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

Similar Threads

  1. Email a report of the current record.
    By jonudden in forum Reports
    Replies: 4
    Last Post: 08-21-2023, 07:37 AM
  2. Variable Email of a Report
    By kylebmorris in forum Reports
    Replies: 6
    Last Post: 07-18-2010, 10:39 PM
  3. Automatically email report
    By Lockrin in forum Access
    Replies: 6
    Last Post: 01-18-2010, 12:35 PM
  4. Email Report for each Vendor
    By dennisg in forum Reports
    Replies: 0
    Last Post: 09-29-2008, 02:43 PM
  5. Another email report question ...
    By valkyry in forum Reports
    Replies: 0
    Last Post: 05-23-2007, 11:42 PM

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