I posted this previously but the subject line may have been confusing. Anyway...
I'm sending email from VBA via Outlook using the following sub:
Sub EmailReport(ReportID As Long, ObjectType As String, ObjectName As String, OutputFormat As String, Subject As String, MsgText As String)
Dim db As Database
Dim rs As DAO.Recordset
Dim strBody As String
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM tblReportRecipients WHERE ObjectToSend = " & ReportID)
rs.MoveFirst
Do Until rs.EOF
DoCmd.SendObject acTable, ObjectName, OutputFormat, _
rs!EmailAddress, "", "", Subject, MsgText, False
'Log emails sent
Call LogEmailsSent(Now(), rs!EmailAddress, ObjectName)
rs.MoveNext
Loop
Set db = Nothing
Set rs = Nothing
End Sub
The sub works fine but the body of the message is a string representing the results of a recordset. In the Immediate window I get a nice string that where each value is separated from the previous value by a tab and each record is a single row in the string.
The problem is that when this string is emailed it gets word-wrapped in Outlook, even though the body area of the Outlook message has plenty of space. It seems to be wrapping it in about a 4 inch area.
Desired result:
101-0000-000.00-00 Supplies jsmith 9/9/06
101-0000-000.00-01 Machinery twatson 9/9/06
Problem I'm getting in Outlook:
101-0000-000.00-00 Supplies
jsmith 9/9/06
101-0000-000.00-01 Machinery
twatson 9/9/06
Thanks!
I'm sending email from VBA via Outlook using the following sub:
Sub EmailReport(ReportID As Long, ObjectType As String, ObjectName As String, OutputFormat As String, Subject As String, MsgText As String)
Dim db As Database
Dim rs As DAO.Recordset
Dim strBody As String
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM tblReportRecipients WHERE ObjectToSend = " & ReportID)
rs.MoveFirst
Do Until rs.EOF
DoCmd.SendObject acTable, ObjectName, OutputFormat, _
rs!EmailAddress, "", "", Subject, MsgText, False
'Log emails sent
Call LogEmailsSent(Now(), rs!EmailAddress, ObjectName)
rs.MoveNext
Loop
Set db = Nothing
Set rs = Nothing
End Sub
The sub works fine but the body of the message is a string representing the results of a recordset. In the Immediate window I get a nice string that where each value is separated from the previous value by a tab and each record is a single row in the string.
The problem is that when this string is emailed it gets word-wrapped in Outlook, even though the body area of the Outlook message has plenty of space. It seems to be wrapping it in about a 4 inch area.
Desired result:
101-0000-000.00-00 Supplies jsmith 9/9/06
101-0000-000.00-01 Machinery twatson 9/9/06
Problem I'm getting in Outlook:
101-0000-000.00-00 Supplies
jsmith 9/9/06
101-0000-000.00-01 Machinery
twatson 9/9/06
Thanks!