DoCmd Statement Email access

mborg

New Member
Joined
Nov 22, 2010
Messages
43
is it at all possible to control the message text in a DoCmd statement? at least have line breaks in the messages?

For instance:
"Dear Name,

Please see attached for your latest balance.

Regards,
Finance"
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
What kind of docmd statement?

Note that you can generally post html tags if you use the php button to enclose the code (available in the advanced editor or otherwise just the same as a code box but with PHP instead of CODE)

Example:
PHP:
<b>stuff</b>
 
Last edited:
Upvote 0
Thanks xenou . Didn't give any thought to the PHP.
 
Upvote 0
What kind of docmd statement?

Note that you can generally post html tags if you use the php button to enclose the code (available in the advanced editor or otherwise just the same as a code box but with PHP instead of CODE)

Example:
PHP:
stuff

Thanks. Here is the statement:
Private Sub Mail_Reimbursement_Summary_Click()
On Error GoTo Err_Mail_Reimbursement_Summary_Click
Dim stDocName As String
stDocName = "Tuition Reimbursement Summary Report"
DoCmd.SendObject acReport, stDocName, , , , , "Reimbursement Summary",

Exit_Mail_Reimbursement_Summary_Click:
Exit Sub
Err_Mail_Reimbursement_Summary_Click:
MsgBox Err.Description
Resume Exit_Mail_Reimbursement_Summary_Click

End Sub

i want to be able to add in a somewhat clean formatted email in the message text, but it does not carryover well...
 
Upvote 0
I would guess that a simple text message is about all you can do here, one without line breaks or html in it.
 
Upvote 0
I use this code, though I can't remember where I found it. You should be able to adjust from mine.
Code:
Private Sub SendToE_Click()
On Error GoTo Err_SendToE_Click

    Dim stDocName As String
    Dim stAddE As String
    stDocName = "NewIndividual"
    stAddE = Me.EmailAddress
    tryTitle = Me.Title
    tryFirst = Me.FirstName
    tryLast = Me.LastName
    
    DoCmd.OpenReport stDocName, acPreview, "IndividualPrintout"
    DoCmd.SendObject acSendReport, _
    stDocName, acFormatPDF, stAddE, , , _
    "Automatic Booking Confirmation", _
    "Dear " & tryTitle & " " & tryLast & Chr(13) & Chr(13) & "Thank you for your booking, if the attachment details are correct, could you please confirm by replying to this email" & Chr(13) & Chr(13) & "Testing", _
    False


Exit_SendToE_Click:
    Exit Sub

Err_SendToE_Click:
    MsgBox Err.Description
    Resume Exit_SendToE_Click
    
End Sub
 
Last edited:
Upvote 0
Thanks marbles.
I'm so used to this stuff that I'd assumed the char(13) type of stuff had been tried already - but if not that would be an obvious attempt.

For instance,
"hello" & char(13) & " world"
or
"hello" & char(13) & char(10) & " world"
or probably equally effective
"hello" & vbNewLine & " world"
 
Upvote 0
There is a VBA constant called vbCRLF for CR and LF (char(13) & char(10) )

You can use:

Code:
"hello" & vbCRLF & " world"
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,351
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top