B
BlueFax
I am using the following code to send an email from within MS Access 2002,
via Outlook 2003. The problem is that each of the resulting lines in the
email end with a space (which causes an onward problem elsewhere). I want to
get rid of the space on each line end, but don't know how to. I have already
tried the Trim command without success (I don't think there is a space to
trim in the Access fields; I think the space is added when the email is
created). An example of the body of the email output by this code is appended
at the very bottom of this question. Any suggestions?
*********************
Private Sub Questionnaire_Click()
Dim sRecipient As String
Dim sSubject As String
Dim sMessage As String
On Error GoTo Err_btnExportEmail_Click
If MsgBox("Are you sure you want to Email a Questionnaire to this
Client?", vbYesNo + vbQuestion) = vbNo Then
Exit Sub
End If
sRecipient = "(e-mail address removed)"
sSubject = "Remoteactivation"
sMessage = sMessage & "[Loginid][email protected]" & vbCrLf
sMessage = sMessage & "
via Outlook 2003. The problem is that each of the resulting lines in the
email end with a space (which causes an onward problem elsewhere). I want to
get rid of the space on each line end, but don't know how to. I have already
tried the Trim command without success (I don't think there is a space to
trim in the Access fields; I think the space is added when the email is
created). An example of the body of the email output by this code is appended
at the very bottom of this question. Any suggestions?
*********************
Private Sub Questionnaire_Click()
Dim sRecipient As String
Dim sSubject As String
Dim sMessage As String
On Error GoTo Err_btnExportEmail_Click
If MsgBox("Are you sure you want to Email a Questionnaire to this
Client?", vbYesNo + vbQuestion) = vbNo Then
Exit Sub
End If
sRecipient = "(e-mail address removed)"
sSubject = "Remoteactivation"
sMessage = sMessage & "[Loginid][email protected]" & vbCrLf
sMessage = sMessage & "
Code:
FG56H77HH89GBH" & vbCrLf
sMessage = sMessage & "[SendtoStart]"
sMessage = sMessage & vbCrLf
sMessage = sMessage & Me.Email & "," & Me.REF & "," & Me.Sal_Too & "," &
Me.PCODE & "," & ReturnLookUp("Lender", "L_ID", Me.LenderID, "L_COMPANY") &
"," & "£" & Me.PAY1 & ";"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[SendtoEnd]"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[CategoryValue1]Ref"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[CategoryValue2]Client"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[CategoryValue3]Postcode"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[CategoryValue4]Lender"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[CategoryValue5]Estimated Claim Value"
sMessage = sMessage & vbCrLf
sMessage = sMessage & "[EOF]"
sMessage = sMessage
SendMailMessage sRecipient, sSubject, sMessage
Exit Sub
Err_btnExportEmail_Click:
MsgBox Err.Description
Resume Next
End Sub
*********************
The resulting email body from the above looks like this:
[Loginid][email protected]
[Surveycode]FG56H77HH89GBH
[SendtoStart]
[email protected],CUS0008,Mr T Customer,TS1 6DG,Big Bank Ltd,£5000;
[SendtoEnd]
[CategoryValue1]Ref
[CategoryValue2]Client
[CategoryValue3]Postcode
[CategoryValue4]Lender
[CategoryValue5]Estimated Claim Value
[EOF]