Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

vba email help

Status
Not open for further replies.

Dtown266

Nuclear
Oct 31, 2006
47
I've create a macro to automatically create an email. But when i run the code. I get an error saying active x component cannot create object (refering to CreateObject("Outlook.Application")). However this code works on other machines. I am a newbie what should i Do?

any and all help will be appreciated

I've posted the code below.

Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olmailItem As Outlook.MailItem
Dim strBodytext As String

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
Set olmailItem = olFolder.Items.Add("IPM.Note")

strBodytext = Msg
With olmailItem
.Subject = Subj
.To = Email
.Body = strBodytext
.Display
End With
Set olmailItem = Nothing
Set olFolder = nothinh
Set olNS = Nothing
Set olApp = Nothing
 
Replies continue below

Recommended for you

Status
Not open for further replies.

Part and Inventory Search

Sponsor