Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing the name of a file with SendObject (Access 97 sr2)

    I have a form which exports a report to a designated drive and sends the same report to a designated email address in Excel format. I have been able to name the report to file fine i.e the file name should be the "Full Age Range" with the current date i.e. "Full Age Range180701" .

    I have been unable to specify a file name for the file when sending it to an email address. The code i'm using is:

    DoCmd.SendObject acSendReport, ReportName, acFormatXLS, _
    "philipj@education.co.uk", , , _
    SubjectText, , False

    Is there another command I can use that includes the file name?
    Any help would be much appreciated.

    (Alternatively, is there a way I can send a specific file in a directory to and email address using code similar to the above?)

  2. #2
    dave_hill
    Guest

    Re: Changing the name of a file with SendObject (Access 97 sr2)

    It might be that its coughing on the filename, even though you're using a variable. I've had problems where XL interprets each space character as the end of the filename. Try reducing the filename to ol' DOS 8.3 format and see if there's a better result.
    You might alternately try Microsoft Knowledge Base article Q161088 - Using Automation to Send a Microsoft Outlook Message or Q153311 - Using Automation to Send a Microsoft Exchange Message. Hope your using one of those mail products...

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Changing the name of a file with SendObject (Access 97 sr2)

    What do you mean, the file name? SendObject is used to send a database object and you've specified the object (report) name. You don't have a file, so which file name are you talking about?
    Charlotte

  4. #4
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing the name of a file with SendObject (Access 97 sr2)

    By file name I meant the name of the file when it has been attached to outlook - when using DoCmd.SendObject acSendReport it automatically uses the name of the table/query/report that is being sent.

    Thanks for your replies, however, I think i've solved it. As I'm having to save the file to disk first anyway, I thought I'd send the file instead of the actual report.
    I found, tucked away in an old database, a function that is called which is based around the following variables:

    Dim ol As New Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim newMail As Outlook.MailItem

    This method seems to work fine.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Changing the name of a file with SendObject (Access 97 sr2)

    That's the automation that Dave referred to. You can see how useful it is.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •