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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

createobject("Outlook.Application")

Status
Not open for further replies.

hugostyles

Programmer
Jun 5, 2001
12
GB
i have a vbs script - email.vbs

its a basic script to open an outlook message.

Set objOutlk = createobject("Outlook.Application")
Set objMail = objOutlk.createitem(olMailItem)

however when i run it, it returns a unspecified error, pointing to the line - "Set objOutlk = createobject("Outlook.Application")"

The script runs fine on my machine, but does not on a client machine. Could anyone help with where the problem might be.

***copy of the entire script ***

Dim objOutlk 'Outlook
Dim objMail 'Email item
Dim strMsg
Const olMailItem = 0
'Create a new message
Set objOutlk = createobject("Outlook.Application")
Set objMail = objOutlk.createitem(olMailItem)
objMail.To = "test@swiftpro.com"
objMail.cc = "" 'Enter an address here To include a carbon copy; bcc

'Set up Subject Line
objMail.subject = "test from script"

'Add the body

strMsg = "Your code rocks!" & vbcrlf
strMsg = strMsg & "I voted and gave you an excellent rating!"
'To add an attachment, use:
'objMail.attachments.add("")
objMail.body = strMsg
objMail.display 'Use this To display before sending, otherwise call objMail.Send to send without reviewing
'Clean up
Set objMail = nothing
Set objOutlk = nothing
'end sub
 
I often have this problem in the environment that i work in as my outlook profile is set for several mailboxes so i have to chose which one i enter to open it. This causes a problem when using the CreatObject function because of the modal dialogue that is open......i found a quick fix to error trap that error and then call the getobject(,"Outlook.Application") function, the only downside to this is the user has to have outlook open to perform the task!

Leadership and learning are indispensable to each other.
John F. Kennedy November 22 1963
 
Re-installed office completely and it solved the problem. yay.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top