Results 1 to 13 of 13

Thread: email (2003)

  1. #1
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    email (2003)

    I have several reports that are generated at points during the day. These reports are generated as rtf files and are sent as email attachments. The attachment is therefore the "report name".rtf. Is there a simple way I can add to the name either any text that I enter or even just a time stamp?

    any help appreciated.

    Regards

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

    Re: email (2003)

    Do you do this interactively, or do you use VBA code?

  3. #3
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: email (2003)

    I use VBA code.

    Thanks

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

    Re: email (2003)

    When you use DoCmd.SendObject, the filename is the caption of the report, unless that is blank, then the report name is used. You could do the following:

    ' Open the report in preview mode
    DoCmd.OpenReport "rptSomething", acViewPreview
    ' Set its caption
    Reports!rptSomething.Caption = "SalesReport" & Format(Date, "yyyymmdd")
    ' Send e-mail
    DoCmd.SendObject acSendReport, , acFormatRTF, "You@Company.com", , , "Test e-mail", "Please see the attachment.", False

    Of course, you must substitute the appropriate names and texts.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: email (2003)

    If my report name is "Search Result Report," what I should put for the space in the following code:

    Reports!rptSomething.Caption

    I putted "Reports!Search_Result_Report.Caption," message pops up report is not exit. So what should I put for space????

    Thanks

    Regards

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

    Re: email (2003)

    If the name of an object contains spaces or punctuation, you must put square brackets [ ] around it:

    Reports![Search Result Report].Caption = "..."

    (For this reason, I never use spaces in the names of tables, queries, forms, etc., and neither in the names of fields in a table and of controls on a form or report)

  7. #7
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: email (2003)

    Thank you so much. It works.

    But I have another question regarding email body. I want three senentes and my contact information in the body with nice format as outlook. How can I do it? I know I have to use string, but I don't what I should put in the "strMBody" to get what I want. Please see the following code:

    Dim strMsgBody As String
    strMBody =

    DoCmd.SendObject acSendReport, , acFormatSNP, "", , , "Test e-mail", strMBody, False

  8. #8
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: email (2003)

    But the report still open as preview after I send the email, how can report close after send the email.

    Regards

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

    Re: email (2003)

    You can insert line breaks by concatenating with vbCrLf, for example

    strMBody = "Dear Customer," & vbCrLf & vbCrLf & _
    "The attached file contains a summary of your orders for last month." & vbCrLf & vbCrLf & _
    "Yours sincerely," & vbCrLf & "Gary Fei"

    will result in
    <hr>Dear Customer,

    The attached file contains a summary of your orders for last month.

    Yours sincerely,
    Gary Fei<hr>
    You cannot specify character formatting such as font, color, bold etc. using SendObject.

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

    Re: email (2003)

    To close the report:

    DoCmd.Close acReport, "Search Result Report"

  11. #11
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: email (2003)

    Thank you so much much. It works.

    But I still have question regarding the report name.

    The report is open as preview after I send the email, how can report close after send the email?

    Regards

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

    Re: email (2003)

    See above.

  13. #13
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: email (2003)

    Thanks! It works. ...

Posting Permissions

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