Using Outlook.Application

GeoNelix

Registered User.
Local time
Today, 09:17
Joined
Aug 27, 2002
Messages
30
I'm sending a file via this code...

Dim olkapps As Outlook.Application
Dim olknamespaces As Outlook.NameSpace
Dim objmailitems As Outlook.MailItem

Set olkapps = New Outlook.Application
Set olknamespaces = GetNamespace("MAPI")
Set objmailitems = olkapps.CreateItem(olMailItem)

With objmailitems
.To = NameRef
.Subject = "Subject Title"
.Body = "Text In Here"
.Importance = olImportanceHigh
.Attachments = "C:\My File Name"
.Send
End With

Set objmailitems = Nothing
Set olknamespaces = Nothing
Set olkapps = Nothing

The problem is with the .Attachments. I keep getting a runtime error which states the parameter value is not valid. I'm sure the path is valid. Is there something I'm not catching here?
 
Why don't you try posting your code that includes your actual file name. We might see something that may not be obvious to you.
 
The .Attachments you are referring to is a read only value. For example you can use the .Attachments.Count to see how many attachments there are in your mail message.

You can use the following to add attachements to your mail message.

Dim objAttachment As Outlook.Attachment

' do all your code here

Set objAttachment = .Attachments.Add("C:\My File Name")

'Then send your message

This will add the file to your email.
 

Users who are viewing this thread

Back
Top Bottom