Link to home
Create AccountLog in
Avatar of PCT3
PCT3

asked on

How do I create an RTF email message from an Access 2007 table memo field in RTF format?

I have an Access table with a field that is MEMO type with RTF format that contains messages, including links, that I want to send to a large email base. I have a program that will create the emails, but with standard text, When I use SendObject to create that email, I get an RTF (HTML?) coded message, not the viewable message I need. Need help!!

 
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

To remove the formatting use the Plaintext() function on the memo field.


Avatar of PCT3
PCT3

ASKER

But then I won't have the links and other RTF that I need?
Can you post your code? If your using the outlook mail item reference you can use MailItem.HTMLBody instead of Mailitem.body.


Let's be clear:...

1. <When I use SendObject to create that email, I get an RTF (HTML?) coded message, not the viewable message>
...meaning you get an RTF (HTML?) coded *Word Attachment*

2. Is This Memo Field's Text Format Property set to "Rich Text"? (Which is really HTML)

3. Is the Hyperlink correctly formatted and Click-able in the memo field? (in MS Access).

4. What Output format are you specifying in the SendObject code (Post all the code please)

5. <I get an RTF (HTML?) coded message, not the viewable message I need. Need help!!
Please explain in detail what you mean by this..

When I do this I get an RTF attachment and the Hyperlink is not visible, but the file is definitely "Viewable".
So also clearly explain exactly what you want from this email...

JeffCoachman

If it turns out that what MikeMcEvoy is a better solution (Using .HTMLBody, instead of .Body), then you won't be able to use SendObject, ...you will have to create the email in code.
See here:
http://support.microsoft.com/kb/161088
Avatar of PCT3

ASKER

boag2000:
1. Here is an excerpt from the message:
‘We Need Your Support’
 
Dear Friends & Supporters:

 Here is an excerpt of what I get:
<div align=center><font face=Arial color=black><strong>'We Need Your
Support'</strong></font></div>

<div>&nbsp;</div>

<div><font face=Arial size=2 color=black>Dear Friends &amp;
Supporters:</font></div>

<div>&nbsp;</div>

2. Memo field is set to RTF
3. Hyperlinks are not clickable from the MS Access Form over the field
4. See code below
5. See answer to 1.

Goal:  I have a routine that I have used for years to send text email messages to distribution lists. Now I want to send an HTML message that includes a number of links and possibly an image.
I currently create the message using a form in MS Access that it stored in a memo field in a table. I then use that field to create the email - (see excerpts of code below):

...
Dim DstMsg As DAO.Recordset
    Dim EmailAdd As String
    Dim Emailcc As String
    Dim Emailbcc As String
    Dim EmailSbj As String
    Dim EmailMsg As String
    Dim EditMsg As Integer
...
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Retrieve the Email message to be sent
' Set subject line, Email message, and prompt yes or no
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Set DstMsg = EDDMailDb.OpenRecordset(EmailMsgFile)
    DstMsg.MoveFirst
    EmailSbj = DstMsg!EmailSubject
    EmailMsg = DstMsg!EmailMsg
    EditMsg = DstMsg!Prompt
...
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Send the Email
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  If SendRecCount > 0 Then
                On Error GoTo ErrorHandlerData
                DoCmd.SendObject acSendNoObject, , acFormatRTF, EmailAdd, Emailcc, Emailbcc, EmailSbj, EmailMsg, EditMsg
    End If

Thanks for your response & any additional help you can provide.
 
You need to be sending HTML mail not rtf.  The 'rich text' in A2007/2010 is HTML not RTF.
Avatar of PCT3

ASKER

peter57r:

I changed outlook options "mail format" from RTF to HTML - made no difference. Is there something else i should do in MS Access?
You need to change the sendobject command to acformathtml
Avatar of PCT3

ASKER

peter57r:

Did that, no change.

 DoCmd.SendObject acSendNoObject, , acFormatHTML, EmailAdd, Emailcc, Emailbcc, EmailSbj, EmailMsg, EditMsg
...Or build the email manually as MikeMcEvoy and I posted above, ...
...and built the "Message" .htmlbody from the memo field.

But try Pete's suggestion first.
If that is what you want, it will be a lot easier to implement than building the email in code...
Mmm...it seems I've been paying too much attention to what you've said rather than what you've done.
Do you have your default email format set to HTML ?

If not, then I don't believe you can create an html message without using full Outlook automation code.
Avatar of PCT3

ASKER

peter57r:

Yes, I changed from RTF to HTML based on your first suggestion
...and the result was...?
Avatar of PCT3

ASKER

boag2000:

As I replied earlier - No change - same problem
Avatar of PCT3

ASKER

Any other suggestions anyone?

I'm wondering if i can just link to an HTML document from MS Access instead of copying to the MEMO field, and then incorporate the entire document in the message field. But that's a little over my head. I actually tried to link to the document, but got an error message from the HTML Import wizard that either the document was empty or too large (document size is 33KB).

Am i just going off on a tangent?

All I'm really trying to do is just create an HTML email within MS Access - don't know why its so difficult, maybe just my inexperience - but i do need to find a solution.

Any and all suggestions ar welcome
<don't know why its so difficult>
1. This is the issue with trying to store "Formatted" data in a database.
Better to store raw text, then do your formatting in the output.
2. Access calls this field "Rich Text" (RTF) when in fact they are really HTML.
3. AFAIK you cannot insert HTML formatting code in a Rich text (HTML) field and have it appear "Formatted"
3. You can't insert HTML into the body of a email using SendObject
...etc.

But lets be clear, ...the ultimate goal is to end up with what?
An email with an HTML Document attachment with formatting?
An email with an HTML Document attachment with click-able links?
An email with an HTML Document attachment with formatting and click-able links?
An email with HTML Body text with Formatting?
An email with HTML Body text with click-able links?
An email with HTML Body text with formatting and click-able links?
...etc

Is the source of this "HTML" to be from the Memo/HTML/RichText field?

Perhaps at this point you should post a sample of this DB, to avoid us spending much more time "Guessing".

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Compile the code. (From the database window, click: Debug-->Compile)
10. Run the compact/Repair utility.
11. Remove any Passwords and/or security.
12. Post explicit steps to replicate the issue.
13. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see the issue, and if applicable, also include a Graphical representation of the Exact results you are expecting.


JeffCoachman
Avatar of PCT3

ASKER

Jeff:

Thank you for your extended response.

I did discover yesterday to my disappointment that the SendObject cmd does not support HTML code - I didn't know that when I posted my original question.

To some of your points/questions

The ultimate goal is to end up with
 "An email with HTML Body text with formatting and click-able links"

The bulk of the Access db is just retrieval  of distribution email addresses from a variety of sources (other dbs, excel files, outlook & exchange files, etc) & related Excel report files & has been working properly for years - but with plain text Body Text - sometimes with the Excel report files as attachments & sometimes with no attachments. So I think it would probably be a waste of your time to wade thru the db itself. The current project calls for HTML Body Text only - no attachments.

The actual original source of the HTML text is a Word HTML document, which I am copy/pasting into the "Memo/HTML/RichText field" - only because that is where the plain text Body Text historically resided (as plain text).

Since SendObject does not support HTML, are there other db cmds that do support HTML and will create Outlook emails? Any other relatively easy solutions? (I'm not an expert db guru - just know enough to be dangerous).

Thanks again




If it were me, I would keep it simple and simply attach the Word doc to a standard email.


Alternatively you can:
Create a table and store the HTML string as *TEXT* in a memo Field
(DO NOT make this Rich text)
Create an email with the automation code in the link I posted
Then insert HTML from the table into the .HTMLBody

Sample attached.

Access-BasicSampleInsertHTMTForm.mdb
Avatar of PCT3

ASKER

boag2000:

Your solution worked! Thanks for the sample automation code. Only issue I have remaining is that the image in the original HTML document did not carry forward to the email - any suggestions on that?. But otherwise, all the links and formatting are perfect.

ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of PCT3

ASKER

Very professionally done