emailing a workbook from within excel

G

Guest

I have tried using both of the following methods, to send an email from
within a workbook, both have failed. The purpose for this is to notify a
manager that a report is to be looked at. I hope that someone can help.
Cheers D



Sub Mail_workbook_Outlook()
'This example send the last saved version of the Activeworkbook
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cboxProjectDirector.Value & "@aqis.gov.au"
.CC = ""
.BCC = ""
.Subject = cboxProjectList.Value & " Status Report" & Format(Date,
"dd/mmm/yy") & ".xls"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub



Private Sub MailWorkbook()

ThisWorkbook.SendMail (cboxProjectDirector.Value &
"@aqis.gov.au",cboxProjectList.Value & " Status Report" & Format(Date,
"dd/mmm/yy"))

End Sub
 
G

Guest

Hi Corey,
I have looked at Ron's website and with the following code I still get an
error message saying object required on the .To= cboxProjectDirector.Value &
"@aqis.gov.au" line of code. D

Sub Mail_workbook_Outlook()
'This example send the last saved version of the Activeworkbook
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = cboxProjectDirector.Value & "@aqis.gov.au"
.CC = ""
.BCC = ""
.Subject = cboxProjectList.Value & " Status Report" & Format(Date,
"dd/mmm/yy") & ".xls"
.Body = "Test email"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top