ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   e-Mail File out of Excel 2003 Macro (https://www.excelbanter.com/excel-programming/380151-e-mail-file-out-excel-2003-macro.html)

Marvin

e-Mail File out of Excel 2003 Macro
 
I am getting a type definition error on the first two DIM statements

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
..To = StudenteMail
..CC = ""
..BCC = ""
..Subject = "Class Progress Audio Report for " & Date
Dim strbody As String
strbody = "Outstanding job today. Please keep up the great work " &
StudentName & vbNewLine & vbNewLine & _
"Kind regards" & vbNewLine & _
"Me"
..Attachments.Add ("C:\Cantillation Sounds\InstructorNotes.wav")
..Display
End With
Set OutMail = Nothing
Set OutApp = Nothing


Tim Lindsley

e-Mail File out of Excel 2003 Macro
 
Try this Marvin.

Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
&tc.

Tim

Marvin wrote:
I am getting a type definition error on the first two DIM statements

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = StudenteMail
.CC = ""
.BCC = ""
.Subject = "Class Progress Audio Report for " & Date
Dim strbody As String
strbody = "Outstanding job today. Please keep up the great work " &
StudentName & vbNewLine & vbNewLine & _
"Kind regards" & vbNewLine & _
"Me"
.Attachments.Add ("C:\Cantillation Sounds\InstructorNotes.wav")
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing



Martin Fishlock

e-Mail File out of Excel 2003 Macro
 
A good page on email is

http://www.rondebruin.nl/sendmail.htm

Try changing your code as follows:

'Dim OutApp As Outlook.Application
'Dim OutMail As Outlook.MailItem
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
' OutApp.Session.Logon ' may need or not
Set OutMail = OutApp.CreateItem(0) '(olMailItem)



--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Marvin" wrote:

I am getting a type definition error on the first two DIM statements

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = StudenteMail
.CC = ""
.BCC = ""
.Subject = "Class Progress Audio Report for " & Date
Dim strbody As String
strbody = "Outstanding job today. Please keep up the great work " &
StudentName & vbNewLine & vbNewLine & _
"Kind regards" & vbNewLine & _
"Me"
.Attachments.Add ("C:\Cantillation Sounds\InstructorNotes.wav")
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing


Marvin

e-Mail File out of Excel 2003 Macro
 
Works perfect now. Many thanks!!!

"Martin Fishlock" wrote:

A good page on email is

http://www.rondebruin.nl/sendmail.htm

Try changing your code as follows:

'Dim OutApp As Outlook.Application
'Dim OutMail As Outlook.MailItem
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
' OutApp.Session.Logon ' may need or not
Set OutMail = OutApp.CreateItem(0) '(olMailItem)



--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Marvin" wrote:

I am getting a type definition error on the first two DIM statements

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = StudenteMail
.CC = ""
.BCC = ""
.Subject = "Class Progress Audio Report for " & Date
Dim strbody As String
strbody = "Outstanding job today. Please keep up the great work " &
StudentName & vbNewLine & vbNewLine & _
"Kind regards" & vbNewLine & _
"Me"
.Attachments.Add ("C:\Cantillation Sounds\InstructorNotes.wav")
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing



All times are GMT +1. The time now is 01:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com