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 TugboatEng 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
Joined
Oct 31, 2006
Messages
47
Location
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top