Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    emailing table (office 2003 SR1)

    Hi all,
    Its been forever since I have posted so here goes. I am currently emailing an access table using the docmd.sendobject method. I designate the format as text and off it goes. This of course sends the file as an attachment. I was approached about actually displaying the text within the body of the message rather than having to open the attachment. Is this at all possible? (I did not see that ability with the access help). If so, where could I look to get a better understanding of the process.

    Thanks
    Kevin
    Kevin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: emailing table (office 2003 SR1)

    That wouldn't be easy. You'd need to use Automation to control Outlook from Access, and you'd need to
    - Export the report to a text or HTML file.
    - Start a new e-mail message in Outlook.
    - Set the Body or HTMLBody property of the message to the contents of the exported file, plus whatever accompanying text you wanted.
    - Set other properties of the message, such as To and Subject.
    - Send or display the message.
    - Delete the exported file.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: emailing table (office 2003 SR1)

    Hans,
    Thanks, I looked into all that you have stated. I managed to get the following code to work...

    DoCmd.TransferText acExportMerge, , "tblEmailChangeListTable", "Cocuments and Settingsmcneilkm.GROTONMy DocumentsEBPricingFilesUploaded.txt ...

    I combine it with the following ...

    Dim vFileContents As String


    Import Text File to get File Name

    Open "Cocuments and Settingsmcneilkm.GROTONMy DocumentsEBPricingFilesUploaded.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, vFileContents
    Loop
    Close #1

    DoCmd.SendObject , , , "LarsonBC@supship.navy.mil;mcneilKM@supship.navy.m il", , , "Pricing and Technical Report Data has been imported to the Pricing Program", "The Following Change Data has been added to the Pricing Program. " & Chr(10) & Chr(13) & Chr(10) & Chr(13) & vFileContents & Chr(10) & Chr(13) & Chr(10) & Chr(13) & "This latest Data from EB is through " & Date & " " & Time & "." & Chr(10) & Chr(13) & Chr(10) & Chr(13) & "If you have any problems please repond to mcneilkm@supship.navy.mil or LarsonBC@supship.navy.mil.", False ...

    The only problem I seem to be encountering is that there are three or four lines in the .txt file and only the very last section is making it to the email. I can't seem to collect all of the contents of the .txt file.
    Do you have any suggestions?

    Thanks
    Kevin
    Kevin

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: emailing table (office 2003 SR1)

    Sorry Hans,

    Right after I posted I realized the problem is in the loop, I think. I think I am just setting the vFileCOntents to the last section of the .txt file. I need to combine all into one long string. I think.
    Kevin

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: emailing table (office 2003 SR1)

    Yep. you could use something like the following:

    Dim vFileContents As String
    Dim vLine As String
    Open "Cocuments and Settingsmcneilkm.GROTONMy DocumentsEBPricingFilesUploaded.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, vLine
    vFileContents = vFileContents & vLine & vbCrLf
    Loop
    Close #1

    Note that you can use the symbolic constant vbCrLf instead of Chr(13) & Chr(10).

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: emailing table (office 2003 SR1)

    perfect, up and running, thanks
    Kevin

Posting Permissions

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