VBA for using Word Doc as Email Body

Status
Not open for further replies.
T

TGlzYWI

I am looking for VBA code to use in Access 2007 that would use a word

document as the body of an email.

I am very well able to automate emails from access. I have created several

applications that automate email from within the access program using .oft

templates, attachments, and other customizations.

However, this client wants to be able to use word documents as the email

template.

Any help would be greately appreciated.
 
This code is adapted from the sample at

http://www.outlookcode.com/codedetail.aspx?id=1333. It requires references

to both Outlook and Word libraries.

Sub SendDocAsMsg()

Dim wd As Word.Application

Dim doc As Word.Document

Dim itm As Outlook.MailItem

Dim ID As String

Dim blnWeOpenedWord As Boolean

On Error Resume Next

Set wd = GetObject(, "Word.Application")

If wd Is Nothing Then

Set wd = CreateObject("Word.Application")

blnWeOpenedWord = True

End If

Set doc = wd.Documents.Open _

(FileName:="C:\Current.doc", ReadOnly:=True)

Set itm = doc.MailEnvelope.Item

With itm

> To = "someone@somewhere.com"

> Subject = "My Subject"

> Send

End With

doc.Close wdDoNotSaveChanges

If blnWeOpenedWord Then

wd.Quit

End If

Set doc = Nothing

Set itm = Nothing

Set wd = Nothing

End Sub

Sue Mosher

"Lisab" <Lisab> wrote in message

news:6935A534-300B-4713-8D2C-A07285E908D7@microsoft.com...
> I am looking for VBA code to use in Access 2007 that would use a word
> document as the body of an email.

> I am very well able to automate emails from access. I have created
> several
> applications that automate email from within the access program using .oft
> templates, attachments, and other customizations.

> However, this client wants to be able to use word documents as the email
> template.

> Any help would be greately appreciated.
 
OH, Thank You Very Much!

"Sue Mosher [MVP]" wrote:


> This code is adapted from the sample at
> http://www.outlookcode.com/codedetail.aspx?id=1333. It requires references
> to both Outlook and Word libraries.

> Sub SendDocAsMsg()
> Dim wd As Word.Application
> Dim doc As Word.Document
> Dim itm As Outlook.MailItem
> Dim ID As String
> Dim blnWeOpenedWord As Boolean
> On Error Resume Next

> Set wd = GetObject(, "Word.Application")
> If wd Is Nothing Then
> Set wd = CreateObject("Word.Application")
> blnWeOpenedWord = True
> End If
> Set doc = wd.Documents.Open _
> (FileName:="C:\Current.doc", ReadOnly:=True)
> Set itm = doc.MailEnvelope.Item
> With itm
> .To = "someone@somewhere.com"
> .Subject = "My Subject"
> .Send
> End With
> doc.Close wdDoNotSaveChanges
> If blnWeOpenedWord Then
> wd.Quit
> End If

> Set doc = Nothing
> Set itm = Nothing
> Set wd = Nothing
> End Sub

> > Sue Mosher
> > >

> "Lisab" <Lisab> wrote in message
> news:6935A534-300B-4713-8D2C-A07285E908D7@microsoft.com...
> >I am looking for VBA code to use in Access 2007 that would use a word
> > document as the body of an email.
> > I am very well able to automate emails from access. I have created
> > several
> > applications that automate email from within the access program using .oft
> > templates, attachments, and other customizations.
> > However, this client wants to be able to use word documents as the email
> > template.
> > Any help would be greately appreciated.


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Using VBA to send Word document as body of message works in 2007, but not in 2003 Outlook VBA and Custom Forms 9
J Specify Font Name or Face using VBA Macro in Word Outlook VBA and Custom Forms 2
J Add Multiple Attachments Sources using VBA in Word Outlook VBA and Custom Forms 6
H using VBA to edit subject line Outlook VBA and Custom Forms 0
Geldner Problem submitting SPAM using Outlook VBA Form Outlook VBA and Custom Forms 2
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
B Looking to get the Recipient email address (or even the "friendly name") from an email I am replying to using VBA Outlook VBA and Custom Forms 4
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
D Remove text in subject using VBA Outlook VBA and Custom Forms 4
P How to export voting results using VBA? Outlook VBA and Custom Forms 2
S Find a cell value in excel using outlook vba Using Outlook 1
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
B query outlook using vba Outlook VBA and Custom Forms 13
P Replying to calendar item using VBA Outlook VBA and Custom Forms 4
H Change Default Email Account Using VBA Outlook VBA and Custom Forms 5
U Using VBA to creat hyperlinks in an email Outlook VBA and Custom Forms 3
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
M Multiple User Defined Fields that can be added, changed, updated using VBA and user form Outlook VBA and Custom Forms 0
Diane Poremsky Create a Series of Tasks using VBA Using Outlook 0
Diane Poremsky Paste clipboard contents using VBA Using Outlook 0
Diane Poremsky Copy New Appointments to Another Calendar using VBA Using Outlook 0
L Clear Offline (Task) Items using VBA Outlook VBA and Custom Forms 0
O How to set subject line in replies using VBA Outlook VBA and Custom Forms 1
O VBA rule on multiple computers using shared mailbox Outlook VBA and Custom Forms 1
G Adding a contact to Outlook with a custom form using Access VBA Outlook VBA and Custom Forms 1
J Using VBA to disable alerts / warnings Using Outlook 2
P Saving All Messages to the Hard Drive Using VBA Outlook VBA and Custom Forms 5
Diane Poremsky Create a list of color categories and merge or restore the list using VBA Using Outlook 0
A Can i apply mail rules to inbox sub folders using VBA Outlook VBA and Custom Forms 2
M using Folders.Count in Excel Vba Outlook VBA and Custom Forms 8
M VBA Send Sales reports using .oft files, originate in Outlook or Excel? Using Outlook 5
A Outlook VBA - moving mail item to public folder using variable within path Using Outlook 6
P Automatic reply on incoming messages in outlook using VBA(only Specifi person) Using Outlook 14
D Update existing rule using VBA Using Outlook 2
A VBA Script to Forward Spam to AntiSpam Provider Using "Blank" Form Outlook VBA and Custom Forms 2
J How to set a flag to follow up using VBA for outlook 2003 Using Outlook 10
J Add categories to Shared Mailbox using VBA Using Outlook 2
R Limiting meeting attendees using VBA or an add-in Using Outlook 9

Similar threads

Back
Top