Hi,
I have a script that no longer works with Outlook 2003. Used to work before the upgrade. Has MS changed the object model for Outlook 2003? I get a "Variable is undefined: 'olMailItem'"
Sub SendMailOutlook(aTo, Subject, TextBody, aFrom, aAttachment)
'Create an Outlook object
Dim Outlook 'As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
'You can display the message To debug And see state
.Display
.Subject = Subject
.Body = TextBody
'Set destination email address
.Recipients.Add (aTo)
.Attachments.Add (aAttachment)
'Set sender address If specified.
Const olOriginator = 0
If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
'Send the message
.Send
End With
End Sub
Thanks,
I have a script that no longer works with Outlook 2003. Used to work before the upgrade. Has MS changed the object model for Outlook 2003? I get a "Variable is undefined: 'olMailItem'"
Sub SendMailOutlook(aTo, Subject, TextBody, aFrom, aAttachment)
'Create an Outlook object
Dim Outlook 'As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
'You can display the message To debug And see state
.Display
.Subject = Subject
.Body = TextBody
'Set destination email address
.Recipients.Add (aTo)
.Attachments.Add (aAttachment)
'Set sender address If specified.
Const olOriginator = 0
If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
'Send the message
.Send
End With
End Sub
Thanks,