Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transferring an attachment in OUTLOOK

Status
Not open for further replies.

cthaxter

Programmer
Aug 2, 2001
71
US
I'm trying to take an attachment from an incoming message and attaching it to a journal item.

I've been able to attach the whole message to the journal item, using this syntax:

If Not objAttachment(1) Is Nothing Then
objNewJournalItem.Attachments.Add objAttachment(1), _
olByValue, 1
End If

where objAttachment(1) is a mailitem and objNewJournalItem is the destination journal item (which has text in it already-I'm using it as a template). The attachment gets embedded to the top of the body of the journal item (its format is rich text).

However, when I try to do the same thing, but objAttachment(1) contains a Word document, I get a run-time error:

"The property does not exist. The field you want to modify is not valid for this type of item."

When I hit Help, it tells me it's an automation error:

"An error occurred while executing a method or getting or setting a property of an object variable. The error was reported by the application that created the object."

Any ideas on how to attach the word document to the journal item?

-Christopher
 
Hi, try to get some ideas from this function that create a Journal Entry.

Function CreateJournalEntry() As Boolean
' This procedure creates a new JournalItem object and
' displays the new object for further input from the user.

Dim objJournalItem As JournalItem

On Error GoTo CreateJournalEntry_Err

' Use the InitializeOutlook procedure to initialize global
' Application and NameSpace object variables, if necessary.
If golApp Is Nothing Then
If InitializeOutlook = False Then
MsgBox "Unable to initialize Outlook Application " _
& "or NameSpace object variables!"
Exit Function
End If
End If

Set objJournalItem = golApp.CreateItem(olJournalItem)

With objJournalItem
.Importance = olImportanceNormal
.ContactNames = Forms!Customers!ContactName
.Companies = Forms!Customers!CompanyName
.Subject = Format(Date, "short date") & " notes regarding " _
& Forms!Customers!CompanyName
.Categories = "Business; Phone Calls"
.StartTimer
.Display
End With

CreateJournalEntry = True

CreateJournalEntry_End:
Exit Function
CreateJournalEntry_Err:
CreateJournalEntry = False
Resume CreateJournalEntry_End
End Function Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top