vba email help
vba email help
(OP)
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
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





RE: vba email help
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376: Eng-Tips.com Forum Policies before posting
Steam Engine enthusiasts
Steam Engine Prints