Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

outlook property for attaching a text file as body

  Asked By: Craig    Date: Aug 15    Category: MS Office    Views: 1075
  

This is related to Excel VBA only because I run everything from an Excel
front-end...



Does anyone know if there is an object in the Outlook object model that
would allow me to use the contents of a text file or word doc as the
body of an e-mail by reference.



My code is below...



Sub Email()

Dim SafeItem As Object, oItem As Object

Dim OLF As Outlook.MAPIFolder

Set SafeItem = CreateObject("Redemption.SafeMailItem")

Set OLF = GetObject("", _


"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInb
ox)

Set oItem = OLF.Items.Add

With oItem

.Subject = SubjectLine

.Body = Body

.Attachments.Add Attachment, olByValue, , "Attachment"

.OriginatorDeliveryReportRequested = False

.ReadReceiptRequested = True

End With

SafeItem.Item = oItem

SafeItem.Recipients.Add recipient1

SafeItem.Recipients.ResolveAll

SafeItem.Send

End Sub



The object above requires a string, which I can do, but life would be so
much easier if I could just tell it to grab the contents of a file.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Ella Brown     Answered On: Aug 15

First of all you posted on an Excel group. You could better search on for
example www.slipstick.com

I should write a function which reads the file  and I should think your
worries are over ( .Body = GetBody("c:\mybodytext.txt" )

 
Didn't find what you were looking for? Find more on outlook property for attaching a text file as body Or get search suggestion and latest updates.




Tagged: