By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

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

P: 78
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.
May 9 '08 #1
Share this Question
Share on Google+
4 Replies


nico5038
Expert 2.5K+
P: 3,072
To get the name of the file, it will need to be saved as a file and then use the sample code from:
http://support.microsoft.com/kb/161088

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

Nic;o)
May 11 '08 #2

ADezii
Expert 5K+
P: 8,638
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:
Expand|Select|Wrap|Line Numbers
  1. 'E-Mail rptEmployee as an Attachment in HTML Format produces the
  2. 'rptEmployee.HTML Attachment(s)  (1 File per Report Page)
  3. DoCmd.SendObject acSendReport, "rptEmployee", acFormatHTML, "HomerSimpson@Verizon.net", , , _
  4.                                "Requested Report", "For Viewing", True
  5.  
  6. 'E-Mail rptEmployee as an Attachment in Text Format produces the
  7. 'rptEmployee.TXT Attachment
  8. DoCmd.SendObject acSendReport, "rptEmployee", acFormatTXT, "HomerSimpson@Verizon.net", , , _
  9.                                "Requested Report", "For Viewing", True
  10.  
  11. 'E-Mail rptEmployee as an Attachment in Snapshot Format produces
  12. 'the rptEmployee.SNP Attachment
  13. DoCmd.SendObject acSendReport, "rptEmployee", acFormatSNP, "HomerSimpson@Verizon.net", , , _
  14.                                "Requested Report", "For Viewing", True
May 12 '08 #3

P: 78
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!
May 13 '08 #4

P: 78
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!
May 13 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.