Solved

Posted on 2013-09-03
Medium Priority
484 Views
Dear Experts

I am building a mailshot database  using Access - this will allow users to send a personalised mailshot (Dear John, Dear Paul etc.) with an attachment & with an RTF signature block (really keen not to use am HTML one as the pictures never seem to come out)

I haven't started on the personalisation piece (which will be a simple rst) but have managed to add the signature block & attachment to the email.  However I cannot add the content of the email (which comes from a Rich Text formatted field [email_body].

I think the adding of the RTF signature block somehow clashes with the formatting of [email_body] so that bit doesn't get added.

Below is the code I am using - can anyone help?

Private Sub SendMail_Click()

'
Dim OutApp As Object
Dim OutMail As Object

' create content Strings
Dim BodyString As String
Dim DefaultSignatureString As String
Dim Signature As String
Dim AttachmentString As String
Dim SubjectLine As String

SubjectLine = Me.Subject_Line
AttachmentString = Me.Attachment
BodyString = Me.Email_Body
DefaultSignatureString = Me.Email_Signature

If Dir(DefaultSignatureString) <> "" Then
Signature = GetBoiler(DefaultSignatureString)
Else
Signature = ""
End If

'Create Outlook Session

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next

With OutMail
.To = "info@digbyedwards.com"
.CC = ""
.BCC = ""
.Subject = SubjectLine
.RTFBody = BodyString & "<br>" & Signature
.Send    'or use .Display
End With

On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

0
Question by:correlate
• 6
• 4

LVL 17

Expert Comment

ID: 39460888
Hi
Please do a Debug.Print of BodyString & "<br>" & Signature and post it up so as we can see the content of this - it may be a case that there is a missing closing tag or something like that
0

Author Comment

ID: 39460926
Hi,

I've put in the code Debug.Print BodyString & "<br>" & Signature , but sadly I have no idea how to see what the result of that is - what do I do?
0

LVL 17

Expert Comment

ID: 39460948
This should out put the details to the debug/output window - From the View menu make sure this window is switched on
0

Author Comment

ID: 39460985
here we go ...

: BodyString : "<div>Hello</div>

<div>&nbsp;</div>

<div><font color=red>Hello in red</font></div>" : String

: DefaultSignatureString : "C:\Users\tcrowfoot\AppData\Roaming\Microsoft\Signatures\New Logo.rtf" : String

0

LVL 17

Accepted Solution

Barry Cunney earned 2000 total points
ID: 39461037
The rtf signature does not appear to have a closing }

It seems to be the call to  Signature = GetBoiler(DefaultSignatureString) that processes the signature.
What does the GetBoiler function do?
0

Author Comment

ID: 39461058
Hi

Thanks for that, the GetBoiler function code is below, I'm not 100% certain what it does, was taken from this question: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_28226876.html

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
ts.Close
End Function

0

LVL 17

Expert Comment

ID: 39462940
As a test, please try excluding the signature and confirm if the e-mail body gets created and formatted OK

Change the line

.RTFBody = BodyString & "<br>" & Signature

to

.RTFBody = BodyString
0

Author Comment

ID: 39462957
Hi

Thanks for that - have just tested it & it comes out all ok
0

Author Comment

ID: 39462968
Argh, actually it doesn't (I had it sending as .HTMLbody as I was trying a few other solutions)

When sending just the body of the email as an RTF the attachment is in the main body of the email rather than in the attachments
0

Author Closing Comment

ID: 39551506
Thanks for your help on this one - the closing "}" was the offending item - there didn't seem to be a way of adding that in in a consistent manner across all user's signature blocks, so have adapted the Db so users copy & paste their signature block into the main body of the email
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.