MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Sending mail without the sheet


Posted by Bryan on September 27, 1999 9:59 AM

I need a macro to send a regular e-mail with an attachment, NOT the sheet. Everything I try ends up sending the sheet too. Any ideas?


Posted by Chris on September 27, 1999 12:03 PM

This will work if you are using Outlook:

Sub SendMail()

Dim OL As Object, MailSendItem As Object

Set OL = CreateObject("Outlook.Application")
Set MailSendItem = OL.CreateItem(olMailItem)

With MailSendItem
.Subject = "Test"
.Body = "Testing 1,2,3"
.To = "bob@bob.com; sam@sam.com"
.Attachments.Add ("C:\File.txt")
.Send
End With

End Sub

Posted by Bryan on September 27, 1999 12:16 PM

How about if I'm using Outlook Express?
It's giving me an error, #429 "ActiveX Component can't create object"

Is there a way to use Express?

Posted by Chris on September 27, 1999 12:52 PM

I'm sure there is...however, I don't have Express so I can't say for sure. Check to see that you have references set up for OLE Automation. You can find this under Tools|References in the VBE. Anybody else have any thoughts???

Chris

Posted by Bryan on September 27, 1999 1:03 PM

I have Outlook Express 5.0 in the reference (MSOE.dll) but now I need to figure out how to write it to use Express... what to replace
'Set OL = CreateObject("Outlook.Application")' with....