Group:  Microsoft Access ยป microsoft.public.access.modulescoding
Thread: Custom message text from file using SendObject

Geek News

Custom message text from file using SendObject
Bob V 11/17/2008 4:35:01 PM
I am just on my way to learning VBA, and it's been great so far. I wondered
if anyone had an idea of how to load the message text field (using SendObject
command in Access 2007) from a file or other source (like a text file),
instead of a fixed message?
RE: Custom message text from file using SendObject
Bob V 11/17/2008 5:13:11 PM
I saw another post with code that is helpful, but I think I have to change
the .Body statement somehow:



Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Britton, Steve")
objOutlookRecip.Type = olTo

' Set the Subject, Body, and Importance of the message.
..Subject = "This is an Automation test with Microsoft
Outlook"
..Body = "This is the body of the message." & vbCrLf &
vbCrLf & _
"W:\purprod\public\Ellis\2008 Tracking Tools\PPV POs
Top 10\PPV Report Forward Looking 11-06-08.xls"
..Importance = olImportanceHigh 'High importance

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

..Save
..Send

End With
Set objOutlook = Nothing
End Sub

"Bob V" wrote:

[Quoted Text]
> I am just on my way to learning VBA, and it's been great so far. I wondered
> if anyone had an idea of how to load the message text field (using SendObject
> command in Access 2007) from a file or other source (like a text file),
> instead of a fixed message?
Re: Custom message text from file using SendObject
"Tony Toews [MVP]" <ttoews[ at ]telusplanet.net> 11/23/2008 12:51:49 AM
Bob V <Bob V[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>I am just on my way to learning VBA, and it's been great so far. I wondered
>if anyone had an idea of how to load the message text field (using SendObject
>command in Access 2007) from a file or other source (like a text file),
>instead of a fixed message?

To create a formatted document to send as an email you will need to
use VBA code to create a largish string. This string will then be
passed to the SendObject command or other method as the body of the
email. For more details including sample air code see my Tips page
on this topic at http://www.granite.ab.ca/access/email/formatted.htm.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net