Copy report to outlook email body

hortizjr59

Registered User.
Local time
Today, 07:01
Joined
Sep 6, 2011
Messages
30
I was wondering if anyone has been able to copy an access report into the body of an outlook email.

I am tryin to copy only the active record. What I have done in the past was as follows:

Private Sub cmdEmailAssignedForm_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[Improvement No] = " & Me.[Improvement No]
DoCmd.OpenReport "ReportEmailNoticeofAssigned", acViewPreview, , strWhere
End If
End Sub

I would like to improve this by just pasting the text on the active record into the email body.

Thanks for your help....

Hector
 
You could just grab values from the current record and concatenate them into a string which could then be used in the body of the e-mail message. Example

Code:
Dim strBody As String
 
strBody = "The Improvement number for this record is " & Me.ImprovementNo & "." & vbCrLf
strBody = strBody & "There are " & Me.WidgetQty & " widgets in this record."
 
With blah blah your e-mail code
    .To = [EMAIL="Someone@somewhere"]Someone@somewhere[/EMAIL]
    .Subject = "New Report"
    .Body = strBody
    etc
End With
 
Thanks Beetle:

I will try this

:cool:
 
im looking at doing something simillar cos people dont seem to want to open an attachment. is there a way to change font size and colour in the body to make it look more like a headed letter?
thanks in anticipation
 
Not from the Access side that I know of. I believe you would need to do the text formatting in Outlook once the e-mail is created.
 
but once that email was sent - how would outlook keep the text format for the next time? can it be saved somewhere?
thanks for replying
 
I did a few minutes of research and discovered that it may be possible to control the formatting from Access VBA by creating an HTML formatted block of text and using the HTMLBody property of the Outlook object model. Here is a discussion on the topic that may be helpul.
 
thanks for the reference - i can see how that would work but for me it is too long winded- my html programming knowledge is not great and would take me a while to create the page however its good to know it can be done and how - -thanks again for the info
 

Users who are viewing this thread

Back
Top Bottom