• email (2003)

    Author
    Topic
    #430019

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1002894

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

      • #1002901

        I use VBA code.

        Thanks

        • #1002905

          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.

          • #1002909

            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

            • #1002910

              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)

            • #1002911

              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

            • #1002917

              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[indent]


              Dear Customer,

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

              Yours sincerely,
              Gary Fei


              [/indent]You cannot specify character formatting such as font, color, bold etc. using SendObject.

            • #1002920

              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

            • #1002922

              See above.

            • #1002915

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

              Regards

            • #1002919

              To close the report:

              DoCmd.Close acReport, “Search Result Report”

            • #1002932

              Thanks! It works. …

    Viewing 0 reply threads
    Reply To: email (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: