emailing workbooks

W

WIlliam Barnes

Using Excel 2000 under Win 2K:

I'd like to write code that will send a workbook as an attachment by email.
I haven't been able to find much in the help files. I tried the following
but got a 1004 Run-Time Error 'Application-Defined or Object-Defined Error'

"MyUserName" is the UserID required to log in to my Email server,
"MyPassword" is the password for the same.

Public Sub MailWkbk()
If IsNull(Application.MailSession) Then
Application.MailLogon "MyUserName", "MyPassword", False
End If

ThisWorkbook.SendMail "MyEmailAddress", "Test Send"

Application.MailLogoff

End Sub

Can anyone suggest some code to accomplish this?
 

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