When using SendObject to email a Report in Snapshot format as an attachment, Access gives the attachment the same name as the Report. Is there a way to modify this name so I could have the attachment created with its own custom name?
There is nothing built in to the DoCmd.SendObject command (which is what *I* use to e-mail forms and reports to people) that will let you specify a name for the attachment, or allow you to specify additional attachments.
One avenue you could pursue: If you have programmatic access to your mail client (whatever it is), you could create the e-mail message with the attachment, allowing the user to edit it (i.e. *not sending* the message immediately). Then perhaps you could figure out how to have Access VBA code reference the message, and work with it, via the mail client's own object hierarchy. If the mail client allows renaming of attachments once attached, and if it exposes itself through programming, you can probably do the renaming via code. And it would probably allow you to initiate the send via code as well. I haven't done all this, but it is the avenue I would pursue. because it's the first one that occurs to me . I have worked with Outlook via VB before, manipulating various parts of the message (but, alas, not attachments). Of course, I don't know what your mail-client is, thus the preceding "ifs".
Another idea, and I admit it is incomplete: Not sure where exactly I'm going with this, but I know where I'm starting. Before/instead of e-mailing the report, *File|Save As/Export...* the report in Snapshot format. I just did it from the menu bar in the user interface, and the option is there, so I'm sure you can get at that through VBA. (With the RunCommand command, if nothing else.) With the Save As, you can specify a different
filename for the output. Hmmm... now, how could you get the created file from your file system into a mail message as an attachment? Can you do so via your e-mail client's programmable accesibility? You can create the e-mail message itself, with no attachment by using:
Code:
DoCmd.SendObject acSendNoObject [...]
(Look in your help file for complete syntax.) I was pleased to find the acSendNoObject option -- which is the default, by the way -- when I re-read the help file a few minutes ago. I hadn't noticed it before, so Thanks .
Hope these suggestions help you on your way to a solution!
BTW, for those looking at this for help with SendObject and Snapshot format, I'll include the annotation I made to my own Help file for the command. For *some* reason, Snapshot format is not a documented choice for e-mailing objects from code, even though it appears in the Send... dialog when you use the menu bars to e-mail a report. I dug and found out how to do it, then added this annotation to my help file for future users of the machine:
-------------- To send a Snaphot file (instead of one of the 4 choices offered below), use this string:
"Snapshot Format (*.snp)"
as <outputformat>.
DETAILS:
You can output in MS-Snapshot format using the information below.
The <outputformat> parameter accepts strings. I found this out by using the Object Browser. The defined constants for this parameter of the command are strings which give a specific format name and associated extension.
[I believe that these strings are checked against information, contained in the Registry, about converters. That is where I found the string I use to produce Snapshot files to send.]
There is no VB- or Access-defined constant for the Snapshot format, but I did see it offered in some -- not all -- contexts using the Send... menu. SO I looked in the Registry for the other items I saw in the menus, and found that "Snapshot Format (*.snp)" was listed near them. When I plugged that in as <outputformat>, it worked!
I also found the list entries for other formats, which may or may not work in some contexts. I haven't tested with them.
The MS-Snapshot viewer is available for free from Microsoft's website.
-- CVigil, 04/15/2002
--------------
-- C Vigil =)
(Before becoming a member, I also signed on several posts as
"JustPassingThru" and "QuickieBoy" -- as in "Giving Quick Answers"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.