UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Losing Rtf Formatting, Office 2013    
 
   
jghogue
post Mar 11 2017, 09:16 AM
Post#1



Posts: 24
Joined: 14-January 16



Greetings All,

I am using Access 2016 and Outlook 2016

I have a routine that sends emails on demand. The body of the email can be pulled from a memo field in an Email Template table and the user's Outlook signature is attached. The resulting email body loses any line feeds embedded within the memo field data. What am I doing wrong? My code is as folllows:

Dim db As Database, sSql As String, Tmp As Recordset
Dim OApp As Object, OMail As Object, strMsgText As String

Set db = CurrentDb
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
OMail.Display
OMail.To = Me.Email
OMail.CC = Nz(Me!CC, "")
If IsNothing(Me!ETno) Then
OMail.Subject = "Unknown"
strMsgText = "Unknown message text"
Else
sSql = "Select * from EmailTemplates where [ETno] = " & Me!ETno
Set Tmp = db.OpenRecordset(sSql, dbOpenSnapshot)
If Not Tmp.EOF Then
Tmp.MoveFirst
OMail.Subject = Tmp!Subject
strMsgText = Tmp!Body
Else
MsgBox "Cannot find Email Template"
Tmp.Close
Set OApp = Nothing
Set OMail = Nothing
Set db = Nothing
Exit Sub
End If
Tmp.Close
End If
OMail.HTMLbody = strMsgText & "</br></br>" & OMail.HTMLbody

Jghogue
Go to the top of the page
 
cheekybuddha
post Mar 11 2017, 10:49 AM
Post#2


UtterAccess VIP
Posts: 9,087
Joined: 6-December 03
From: Telegraph Hill


Hi jghogue,

The text stored in your tables probably doesn't include html line break tags (<br>).

Try:
CODE
' ...
strMsgText = Replace(Tmp!Body, vbCrLf, "<br>")
' ...


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
jghogue
post Mar 11 2017, 10:55 AM
Post#3



Posts: 24
Joined: 14-January 16



d,

Solved the problem.!Thank you for your prompt reply.

jghogue
Go to the top of the page
 
cheekybuddha
post Mar 11 2017, 11:04 AM
Post#4


UtterAccess VIP
Posts: 9,087
Joined: 6-December 03
From: Telegraph Hill


By the way, if the template is not found you will likely generate an error in your last line of code.

Probably better to place it within the True portion of the If test.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
jghogue
post Mar 11 2017, 11:40 AM
Post#5



Posts: 24
Joined: 14-January 16



Hi d,

I have to trap if the user actually sent the email. I had no problem when I used the sendobject format. Now that I have switched to html format, how can I capture what the user did?

jghogue
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd September 2017 - 10:58 PM