PDA

View Full Version : How to email a rtf file as the body of an email



Jeff B
08-06-2005, 01:15 PM
From within Access (2003), using VBA, I've opened a RTF file, and changed it. Now I need to send it as the BODY of an email. Can't seem to figure this out. Any ideas?
Thanks,
Jeff B

xCav8r
08-06-2005, 01:44 PM
:hi:

Welcome to VBAX. I think you're looking for the MessageText parameter of the SendObject Method. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acmthactSendObject_HV05186513.asp

:yes

Jeff B
08-06-2005, 02:10 PM
Not sure I follow you, the MessageText parameter allows me to insert plain text in the body, not RTF. It seems the SENDOBJECT only allows me to send one of the objects (see below) as an ATTACHMENT, and only allows PLAIN TEXT in the body.
The sendobject has these parameters:
expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

where ObjectType can be one of
acSendDataAccessPane acSendForm acSendModule acSendNoObject default acSendQuery acSendReport acSendTable Perhaps I'm not understaning this SENDOBJECT correctly??

xCav8r
08-06-2005, 04:57 PM
I didn't pay close enough attention to RTF. Just thought you wanted to know how to put text into the body of an email. Sorry about that. Anyway, AFAIK, what you want to do can't be done with Access. You'll need to do that in Word or Outlook.

One of our users posted this in a recent thread. You could use this code to send the RTF as an attachement.

http://www.vbaexpress.com/forum/showthread.php?t=4358

In the meantime, I wrote one of the other moderators to see which forum would be the most appropriate one for this question. I'll move the thread to Word or Outlook when I get some feedback from him.

Jeff B
08-06-2005, 10:24 PM
Thank you for your response. Yes, this is a bit tricky. From within Access (2003) I'm composing invoices by inputting data from the database into a RTF template file. Then while still in Access I need to insert the completed RTF invoice into the body of the Email, and send it (I'll be satisfied to at least put them in the OUT box). There are at least 100 invoices each time, so I can't afford to deal with any security warnings etc.

I see it can be done manually from inside WORD, that is you can send any document as the body of an email. When I looked at the sent email it appeared that the message body had been formatted to HTML (XML?).
Perhaps XML is involved in this somehow.

Thank you for your assistance, very much appreciated (this is driving me crazy)!

xCav8r
08-06-2005, 10:34 PM
It's not okay then to use the rtf as an attachment? It's gotta be in the body of the email? And, you didn't say. Do you have both Word and Outlook?

P.S. Is it not possible to select a CA province for a flag?

Norie
08-07-2005, 06:07 AM
Why not use Mail Merge in Word with Access as the data source?

Or you could write code that plugs the data into an existing Word template using bookmarks.

I know this is possible as I've done it myself. I'll have a look and see if I can dig out the code.

Jeff B
08-07-2005, 07:26 PM
It's not okay then to use the rtf as an attachment? It's gotta be in the body of the email? And, you didn't say. Do you have both Word and Outlook?

P.S. Is it not possible to select a CA province for a flag?

The invoice can also be in an attachment but it must be in the body.
I have the complete Office 2003 Pro.
I should clarify, I need to do the automation from within Access (using VBA).

Now I'm wondering if I could create a template invoice email in Outlook, and then use VBA from within Access to access it and insert the individual data.

(Can't select Ontario - doesn't offer that choice)

xCav8r
08-08-2005, 09:02 AM
The invoice can also be in an attachment but it must be in the body.
I have the complete Office 2003 Pro.
I should clarify, I need to do the automation from within Access (using VBA).

Now I'm wondering if I could create a template invoice email in Outlook, and then use VBA from within Access to access it and insert the individual data.

(Can't select Ontario - doesn't offer that choice)

I understand that you need to do the automation within Access, but it could be done from any Office application, and I think you might get more exposure with people who know how to automate Outlook in the Outlook forum, but we'll leave it here for the time being with the hope that they'll come read and offer solutions. :)

I made another attempt to contact my friend, Moose, who I'm sure will be able to help. Let's see if my second PM gets more traction than the first.

No Ontario? Argh!!!! :p

MOS MASTER
08-08-2005, 10:01 AM
There are at least 100 invoices each time, so I can't afford to deal with any security warnings etc.

Hi Jeff, :yes

Well that's a problem indeed!

Outlooks security cannot be turned off! However there are ways to bypass the security and so you can utilize Mark's code in the link thread.

But all the good ones involve installing a DLL or a program to your computer to help you tackle that Outlook security.

All possible options are listed here:
http://www.outlookcode.com/d/sec.htm

We need to find out first if you're able to install for instance Outlook Redemption DLL to fix this problem.

So are you allowed to do that? :whistle:

MOS MASTER
08-08-2005, 10:02 AM
No Ontario? Argh!!!! :p

If so...pm Jake and he'll add it! :yes

xCav8r
08-08-2005, 10:04 AM
Moose, have you code to stick rich text into the body of an outlook message? :giggle

MOS MASTER
08-08-2005, 10:14 AM
Moose, have you code to stick rich text into the body of an outlook message? :giggle

Not on the shelf but its doable for sure!

But for me the big question here is if he can utilize Redemption or a other tool to bypass the security.

If not then he'll better stick to mailing as attachment with SendObject method! :whistle:

jadedata
08-08-2005, 10:33 AM
You can not use the RTF itself as the email body. You could only use the content from the rtf.

The best way I can recomment to do this is using HTML content for the email body.

-j-

mdmackillop
08-08-2005, 10:57 AM
Hi Jack,
Welcome to VBA Express.
It's great to see another real Access expert joining us.
Regards
MD

MOS MASTER
08-08-2005, 12:56 PM
Hi And welcome to VBAX! :hi:


The best way I can recomment to do this is using HTML content for the email body.


If the emailbody requires formatting like RTF or HTML then I agree you should use the "HtmlBody" property of the item.

To retrieve the HTML you'd best save the RTF file as (*htm or *html) and then use FileSystemObject to read it as text to pass to the HtmlBody.

But for me the biggest issue here is the security problem. This always provides the biggest challenge in Outlook.

:whistle:

Jeff B
08-08-2005, 03:36 PM
Wow... many opportunities here. THANKS!
Right now I have had to move on to other things and will get back to trying some of the suggestions ASAP. For now it will have to be an attachment. Thanks for your wonderful assistance!!!

xCav8r
08-08-2005, 08:22 PM
Hi Jack,
Welcome to VBA Express.
It's great to see another real Access expert joining us.
Regards
MD

Very cool. Welcome, Jack. Your expertise would be a welcome addition to VBAX. I hope you find a home here. :yes

MOS MASTER
08-09-2005, 09:14 AM
Wow... many opportunities here. THANKS!
Right now I have had to move on to other things and will get back to trying some of the suggestions ASAP. For now it will have to be an attachment. Thanks for your wonderful assistance!!!

Glad to see you've found a entry to your sollution. :yes

Keep us posted! :whistle:

xCav8r
08-10-2005, 03:57 PM
If so...pm Jake and he'll add it! :yes

I did. We now have a flag for Ontario. :)

Jeff B
08-11-2005, 10:11 PM
I did. We now have a flag for Ontario. :)
great thanks. You have a great site here, I'll be sure to tell all my programming buddies!

MOS MASTER
08-14-2005, 02:45 PM
great thanks. You have a great site here, I'll be sure to tell all my programming buddies!

Thanx for the kuddos on the site..We love it as well! :cloud9:

And yes please tell all your friends to join in the talk about VBA. :yes

geekgirlau
08-14-2005, 05:47 PM
See if this helps:

http://support.microsoft.com/kb/172038/EN-US/

Jeff B
08-14-2005, 09:43 PM
That looks quite useful. Thanks! I'm still busy with another project but when I have the chance I'll let you know how it worked out. Thanks again!!