469,906 Members | 2,215 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,906 developers. It's quick & easy.

emailing report as attachment

264 256MB
i have a database where i am trying to email a report as an attachment, it works fine but since it is an .rtf file the conversion is messy... i was wondering if i can do it as a pdf or some other easily read file... any help is greatly appreciated. thanks.. here is my current code.. and also some info on the report is populated by the current record i am on in the form...

Expand|Select|Wrap|Line Numbers
  1. On Error GoTo cmdEMailReport_Click_Err
  2.  
  3. Dim strMsg As String, strTitle As String
  4. Dim intStyle As Integer
  5. Dim StrCriterion As String
  6. Dim strMailto As String
  7. Dim strSubject As String
  8. Dim strDocName As String
  9.  
  10.  
  11. 'This forces the record to be saved.
  12.  
  13. 'DoCmd.RunCommand acCmdSaveRecord
  14.  
  15.  
  16. 'There is no need to check if the form is blank (as with report and preview) as the cmdEmailReport button will
  17. 'only be enabled if there is and e-mail address in CustomerEMailAddress field.
  18.  
  19.  
  20.  
  21. 'If there is nothing in the subject control (CustomerEMailSubject) then the subject field in the e-mail client
  22. 'will display the name of the report.
  23.  
  24. 'If IsNull(Me!CustomerEMailSubject) Or Me!CustomerEMailSubject = "" Then
  25.  
  26.  
  27.     strMailto = Me.MAILINGEMAILADDRESS
  28.     strDocName = "rptmembershiprenewal"
  29.     StrCriterion = " [lngRegistrationYear]=" & Forms![frmmembership].[lngRegistrationYear]
  30.  
  31. 'This will hide the customer form
  32.  
  33.  
  34. Me.Visible = True
  35.  
  36.  
  37.  ' This will open the report with the same primary key as the form on the screen.In preview mode
  38.  
  39.     DoCmd.OpenReport "rptmembershiprenewal", acPreview, , StrCriterion
  40.  
  41.  
  42.  
  43. 'This will minimize the report, whilst the e-mail in being prepared, I have tried not to have it open in preview but
  44. 'cannot get it to work.
  45.  
  46.     DoCmd.Minimize
  47.  
  48.  
  49.  
  50.  
  51.  
  52. 'This will create the e-mail
  53.  
  54. ''DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto, "", "", strDocName, , True, ""
  55. DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto, "", "", "Membership Renewal", , True, ""
  56.  
  57.  
  58.    'Tbis explains all the section of the e-mail see SendObject in help
  59.       'Explanation DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]
  60.  
  61.  
  62.  
  63. 'Else
  64.  
  65. 'If there is something in the subject control (CustomerEMailSubject) then the subject field in the e-mail client
  66. 'will display that data.
  67.  
  68.     'strMailto = Me.MAILINGEMAILADDRESS
  69.     'strSubject = Me.CustomerEMailSubject
  70.     'strDocName = "rptmembershiprenewal"
  71.     'StrCriterion = " [lngRegistrationYear]=" & Forms![frmmembership].[lngRegistrationYear]
  72.  
  73.  
  74. 'This will hide the customer form
  75.  
  76.  
  77. 'Me.Visible = False
  78.  
  79.  
  80.  
  81.  
  82.  'DoCmd.OpenReport "rptmembershiprenewal", acPreview, , StrCriterion
  83.  
  84.  
  85.  
  86. 'This will minimize the report, whilst the e-mail in being prepared, I have tried not to have it open in preview but
  87. 'cannot get it to work.
  88.  
  89.     'DoCmd.Minimize
  90.  
  91.  
  92.  
  93.  
  94.  
  95. 'This will create the e-mail
  96.  
  97. 'DoCmd.SendObject acReport, strDocName, "RichTextFormat(*.rtf)", strMailto, "", "", strSubject, , True, ""
  98.  
  99.    'Tbis explains all the section of the e-mail see SendObject in help
  100.       'Explanation DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]
  101. 'End If
  102.  
  103. 'This will close the report when you either cancel or send the e-mail. The Frm_Customer will open
  104. DoCmd.Close acReport, "rptmembershiprenewal"
  105.  
  106.  
  107. cmdEMailReport_Click_Exit:
  108.     Exit Sub
  109.  
  110. cmdEMailReport_Click_Err:
  111.     MsgBox Error$
  112.     Resume cmdEMailReport_Click_Exit
Jul 30 '09 #1
1 2360
ADezii
8,800 Expert 8TB
@didacticone
Assuming your Recipients have the Snapshot Viewer, a Snapshot (*.snp), in my opinion, is an excellent Format for Report generation. A Report Snapshot file contains a copy of each Page of a Report and preserves the Report's two-dimensional Layout, Graphics, and other Embedded Objects.
Aug 1 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Bob-O | last post: by
1 post views Thread by Pommy_g | last post: by
5 posts views Thread by szag via AccessMonster.com | last post: by
3 posts views Thread by dee | last post: by
1 post views Thread by =?Utf-8?B?U2FpIFZhamph?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.