I have pieced together a macro that takes data from a query to populate and send an automatic outlook message based on a customer table and template table. The template table has an EmailBody field of type Memo that is merging with the customer table to formulate the EmailBody field for each customer in the query. However, when the email sends through Outlook it always truncates it to 255 legible characters and then adds a few foreign characters in at the end - never including the whole message. Any suggestions?
Code:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM tblCustomer WHERE CustomerID=" & lngCustomerID)
rst.MoveFirst
XXXTitleXXX = Nz(rst!Title, "")
XXXFirstNameXXX = Nz(rst!FirstName, "")
XXXLastNameXXX = Nz(rst!LastName, "")
XXXrFirstNameXXX = Nz(rst!rFirstName, "")
XXXrLastNameXXX = Nz(rst!rLastName, "")
XXXExpiredDateXXX = Nz(rst!ExpiredDate, "")
rst.Close
Set rst = Nothing
Set db = Nothing
End Function
Sub ExpirationSub()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rs As DAO.Recordset
Dim objMessage
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM qrySubscriptionDue WHERE Says < 90")
On Error Resume Next
'Get Outlook if it's running
Set oApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oApp = CreateObject("Outlook.Application")
Started = True
End If
Do While Not rst.EOF
Set oItem = oApp.CreateItem(olMailItem)
With oItem
.BodyFormat = olFormatHTML
.To = rst!EmailAddress
.Subject = "PLEASE READ: Impending Resource Expiration Notification"
.Body = rst!EmailBody
.Importance = olImportanceHigh
'Send the email
.Send
End With
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
Set oItem = Nothing
If Started Then
oApp.Quit
End If
End Sub