Rename attachment sent via email/How does Access name attachments?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kpfunf
    New Member
    • Feb 2008
    • 78

    Rename attachment sent via email/How does Access name attachments?

    When I email a report via macro or vba code, the attached report is named "Fuel Quote Report.(ext)". I have no idea how this name is used. I have three seperate macros sending three seperate reports. Each macro is named after the report, which are all named differently. The subject messages are different. Yet, in each email, the attachments are all named the same. How does Access name the attachments? I even tried different formats (rtf, snp), to no avail. I also tested in a seperate database with other reports; again, the attachment is not actually named as the exact report name or macro name.

    I figure there's some property I'm overlooking. Does anyone know how Access names the attachments? I've done some testing with various objects, and cannot find a common link (sent one form, and the attachment was named for the table tied to the form, tried another form, and the attachment was named for the form). Thanks.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    To get the name of the file, it will need to be saved as a file and then use the sample code from:


    The attachment will be the filename (without the path).

    Nic;o)

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by kpfunf
      When I email a report via macro or vba code, the attached report is named "Fuel Quote Report.(ext)". I have no idea how this name is used. I have three seperate macros sending three seperate reports. Each macro is named after the report, which are all named differently. The subject messages are different. Yet, in each email, the attachments are all named the same. How does Access name the attachments? I even tried different formats (rtf, snp), to no avail. I also tested in a seperate database with other reports; again, the attachment is not actually named as the exact report name or macro name.

      I figure there's some property I'm overlooking. Does anyone know how Access names the attachments? I've done some testing with various objects, and cannot find a common link (sent one form, and the attachment was named for the table tied to the form, tried another form, and the attachment was named for the form). Thanks.
      I figure there's some property I'm overlooking. Does anyone know how Access names the attachments?
      I don't think that you are overlooking anything. To the best of my knowledge, the standard naming convention for E-Mailing Access Objects as Attachments is the Base File name plus the appropriate Extension for the Format in which it was sent, namely:
      [CODE=vb]
      'E-Mail rptEmployee as an Attachment in HTML Format produces the
      'rptEmployee.HT ML Attachment(s) (1 File per Report Page)
      DoCmd.SendObjec t acSendReport, "rptEmploye e", acFormatHTML, "HomerSimpson@V erizon.net", , , _
      "Requested Report", "For Viewing", True

      'E-Mail rptEmployee as an Attachment in Text Format produces the
      'rptEmployee.TX T Attachment
      DoCmd.SendObjec t acSendReport, "rptEmploye e", acFormatTXT, "HomerSimpson@V erizon.net", , , _
      "Requested Report", "For Viewing", True

      'E-Mail rptEmployee as an Attachment in Snapshot Format produces
      'the rptEmployee.SNP Attachment
      DoCmd.SendObjec t acSendReport, "rptEmploye e", acFormatSNP, "HomerSimpson@V erizon.net", , , _
      "Requested Report", "For Viewing", True[/CODE]

      Comment

      • kpfunf
        New Member
        • Feb 2008
        • 78

        #4
        I'm thinking it's not the base file name, only in that I keep changing the name of the report, and it's name as an attachment stays the same. Odd. I tried to change the name of the underlying query (it seemed to be using that name), but that didn't work. Anyway, thanks for the suggestions!

        Comment

        • kpfunf
          New Member
          • Feb 2008
          • 78

          #5
          Okay, I found it. The attachment takes the name of the caption. I had copy/pasted similar reports, and edited the guts of the report, but not the captions; hence, they all were coming out with the same name!

          Comment

          Working...