objOutlookMsg.body

  • Thread starter Thread starter Carl J. Hixon
  • Start date Start date
C

Carl J. Hixon

I have a module that I am using to send an e-mail message to members of our
group. (850ish members) The module individually addresses each message to
keep our members information private. In my module, I use:

.Body = "Blah Blah Blah..." & vbCrLf & vbCrLf

..Body is usually a short sentance about the attachment. and I use:

Set objOutlookAttach = .Attachments.Add(AttachmentPath)

to add an attachment. Now our group has decided that they do not want to
send any e-mail messages with attachments due to all of the virus activity
out there. So now my problem is... .Body =" blah blah blah" doesn't work
so well. Is there some way that I can use .Body to point to a plain text
file on my hard drive and have that inserted into the outlook message as
plain text? Any help is GREATLY appreciated.

Thanks,
Carl
 
Thanks Savi. I haven't been able to test it yet because I ran into another
problem with my code. (attached below) I had this module working a while
ago but, I recently upgraded my outlook and suspect that to be my problem.

I get the following compile error, "Object Library Feature Not Supported"
for <objOutlook> here:
Set objOutlook = CreateObject("Outlook.Application")

Anybody have any ideas?

Thanks,
Carl
--------Begin Code------------
Option Compare Database

Option Explicit

Sub SendMessage(MailRecip, Optional AttachmentPath)
'SendMessage subroutine for sending a message using the default user
'in Microsoft Outlook. Use this subroutine by passing 1 or 2 parameters
'MailRecip is a text string containing the Recipients Name which must
'be in the Outlook Contacts Directory (Commented out below).
'AttachmentPath is optional and it is a tring which contains the full
path
'and file name of a file to be attached.
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(MailRecip)
objOutlookRecip.Type = olTo

'Add the CC recipient(s) to the message.
'Set objOutlookRecip = .Recipients.Add("BJ Hixon")
'objOutlookRecip.Type = olCC

'Set the Subject of the message.
.Subject = "OAA UPDATE: Events, Hangars, Noise, Committees,
Membership, 2004 Critical..."
'Read in body of the message from text file.
Open "c:\message.txt" For Input As #1
Do While Not EOF(1) 'Loop until end of file
Input #1, TextLine
.Body = .Body + TextLine
Loop
Close #1
'Set importance of the message.
.Importance = olImportanceNormal

'Add attachments to the message.
'If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
'End If

'No need to resolve each name with outlook contacts.
'Resolve each Recipient's name.
'Uncomment next 5 lines if resolve is desired.
'For Each objOutlookRecip In .Recipients
'objOutlookRecip.Resolve
'If Not objOutlookRecip.Resolve Then
'objOutlookMsg.Display
'End If
'Next
.Send

End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
----------------End Code------------------------
 
Back
Top