Problem create mail with Vista

A

azzzanetti

To automatically create a mail with an attachments I've always used
this code:

Dim allegati As Outlook.Attachment

Set OutLk = CreateObject("Outlook.Application")
Set email = OutLk.CreateItem(0)
With email
..Subject = "Subject"
..Body = "Body"
Set allegati = .Attachments.Add("c:\test.txt")
..Display
End With
Set email = Nothing
Set OutLk = Nothing

I use this code since 2-3 years ago, I have the references included in
the project and the only problem is that with Wista it doesn't work
and I get this error: "Object dosent support this property or method"
I use Outlook2003, if I try the same code with another PC with WinXP
or Win2000 everything works fine.

Thank you.
 
S

Sue Mosher [MVP-Outlook]

Where are you writing this code? Outlook VBA or somewhere else? What statement raises the error?
 
A

azzzanetti

Where are you writing this code? Outlook VBA or somewhere else? What statement raises the error?

This code is written in VB6, the statement that raise the error is the
first: Set OutLk = CreateObject("Outlook.Application")

Sorry for the imprecision.
 
S

Sue Mosher [MVP-Outlook]

If you get an error from code statements like these:

Dim ol as New Outlook.Application

Set ol = CreateObject("Outlook.Application")

the cause may be an anti-virus program on your computer that has a feature to block Outlook scripting. If so, the solution is to turn off the script blocking feature. You may need to contact technical support for your anti-virus program to find out how to do that.

I've also seen reports that setting the server parameter can resolve this problem in some situations:

Set ol = CreateObject("Outlook.Applicaton", localhost)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top