sending a word document as the body of an email in access 2003 (1 Viewer)

I7arkHiro97

New member
Local time
Today, 08:19
Joined
Jun 29, 2010
Messages
2
Hi,

I am a beginner to VBA. I am using MS access 2003. I found some code that works great for sending automatic emails to a list of recipients. My email addresses are housed in a table on access and they are pulled into a query to send an email to only those who are listed in my query.

Right now the code uses a text document as the body of the email. Is there a way to change the code in order to use a word document instead of a text document? I also want it to transfer the text and pics from the word document over to the body of email exactly how it looks. For example if the text is bold or colored, thats how I want it to look in the body of the email. However i did find code that will use a word document as the body of an email on word, I would like to do that but using VBA on access 2003.

The second thing is that I will be sending an email to a massive list of recipients. I was able to use the code to add all the email addresses to a single email on the TO: recipient from my list of email addresses from my query. Can the code be altered to show all the email addresses as Undisclosed Recipents when the email is sent? The main thing is that I want to ensure the recipients can't see the massive email list of other reciepents. Also if they click the reply to all by accident, I want them to only be able to send a reply back to just the sender.

I would really appreciate all the help. Thank you for taking the time:)

Here is the code I am using:

Public Function SendEMail()

Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String

Set fso = New FileSystemObject
Subjectline$ = InputBox$("Please enter the subject line for this mailing.", _
"We Need A Subject Line!")

If Subjectline$ = "" Then
MsgBox "No subject line, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "E-Mail Merger"
Exit Function
End If
BodyFile$ = InputBox$("Please enter the filename of the body of the message.", _
"We Need A Body!")
If BodyFile$ = "" Then
MsgBox "No body, no message." & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "I Ain??t Got No-Body!"
Exit Function
End If

If fso.FileExists(BodyFile$) = False Then
MsgBox "The body file isn??t where you say it is. " & vbNewLine & vbNewLine & _
"Quitting...", vbCritical, "I Ain??t Got No-Body!"
Exit Function
End If
Set MyBody = fso_OpenTextFile(BodyFile, ForReading, False, TristateUseDefault)
MyBodyText = MyBody.ReadAll

MyBody.Close
Set MyOutlook = New Outlook.Application

Set db = CurrentDb()

Set MailList = db.OpenRecordset("MyEmailAddresses")

Set MyMail = MyOutlook.CreateItem(olMailItem)

Do Until MailList.EOF

MyMail.Recipients.Add = MailList("email")

MailList.MoveNext

Loop

MyMail.Subject = Subjectline$

MyMail.body = "Dear Recipient(s)" & "," & vbNewLine & vbNewLine & MyBodyText

MyMail.Display

Set MyMail = Nothing
Set MyOutlook = Nothing
MailList.Close
Set MailList = Nothing
db.Close
Set db = Nothing

End Function
 

darbid

Registered User.
Local time
Today, 17:19
Joined
Jun 26, 2008
Messages
1,428
Right now the code uses a text document as the body of the email. Is there a way to change the code in order to use a word document instead of a text document? I also want it to transfer the text and pics from the word document over to the body of email exactly how it looks.
From what I know you have at least 3 choices of email types - text, HTML or Word. I would have thought that you could use HTML or Word.

If you want to simply copy from an existing word document then you of course would have to use WORD. In Outlook this means you need to start the WordEditor.

I think this example will help you

http://community.brendonraw.com/blogs/office_vba/archive/2005/10/14/24.aspx
 

I7arkHiro97

New member
Local time
Today, 08:19
Joined
Jun 29, 2010
Messages
2
From what I know you have at least 3 choices of email types - text, HTML or Word. I would have thought that you could use HTML or Word.

If you want to simply copy from an existing word document then you of course would have to use WORD. In Outlook this means you need to start the WordEditor.

I think this example will help you

http://community.brendonraw.com/blogs/office_vba/archive/2005/10/14/24.aspx


Thanks for that site, it looks to be what I am looking for. I can read some of it but not all of. Remember I am a beginner at this. Can you should me how I would change my existing code to use a word document as the body instead of a txt document? Show me where you change the code and to what for it to work. Thanks again
 

darbid

Registered User.
Local time
Today, 17:19
Joined
Jun 26, 2008
Messages
1,428
Thanks for that site, it looks to be what I am looking for. I can read some of it but not all of. Remember I am a beginner at this.

If you really want to use your code then you need to start your changes after you set MyMail.

You need to look at the code i suggested and the Getinspector part. This is how you bring Word into outlook.

In the code I gave you it also copies a word doc and then pastes it into the outlook mail.

Try putting it together and then come back here and ask a specific question with your attempted code.
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 08:19
Joined
Nov 8, 2005
Messages
3,294
remember how it looks to you - is not how it might be received ....
not everyone has outlook (bear this in mind)
 

Users who are viewing this thread

Top Bottom