Just email file

  • Thread starter Thread starter strober
  • Start date Start date
S

strober

Hi Bob,

Thanks for the web address. Checked it out and it has a
HEAP of great stuff, some of it over my head!, am trying
some of it now.

What is the easiest code to attatch a filename to an email
and insert something into the heading and a couple of
lines in the body of the email?

Cheers,

strober
 
There isn't anything easy to do that. If you can skip putting in a couple
of lines, you can just use

Workbooks("Myworkbook.xls").SendMail _
Recipient:="(e-mail address removed)", _
Subject:="My Subject"

The step atfter that is a big one.
 
Hi

I just reply to your other thread about the htm file

What is the easiest code to attatch a filename to an email
and insert something into the heading and a couple of
lines in the body of the email?

See the examples for Outlook on my site and check out this part(Outlook Tips) for
adding some lines ito the body
http://www.rondebruin.nl/sendmail.htm#Outlook

See this lines for attaching files

'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
 
Hi Tom,

I cut & paste that code put in my filename & subdir and it
had a compile error.


any ideas?

strober
 
Workbooks("Myworkbook.xls").SendMail _
Recipients:="(e-mail address removed)", _
Subject:="My Subject"

Recipients should be plural.

You probably shouldn't use code if you can't debug it and maintain it.
Hightlight SendMail in the VBE and hit F1. It would be easy to spot the
problem.
 
Hi Ron,

Yeah I posted a 'new' message instead of replying before.
Thanks for the headsup with your site. It has a LOT of
great stuff on it.

I am successfully creating a .htm file of a selected range
on a single sheet.

I need to be able to email this file as an attachment and
put some text subject and several lines of text in the
body.

Some of the stuff on your site was a little over my head.
Sorry most of this stuff is new to me.

I tried the following code from your site but didnt know
how to setup the outlook.application stuff.


Sub Mail_workbook_Outlook()
'This example send the last saved version of the
Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'In Excel 97 use ActiveWorkbook.Path & "\" &
ActiveWorkbook.Name
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub



Cheers,

strober
 
) Go to the VBA editor, Alt -F11
2) Tools>References in the Menu bar
3) Place a Checkmark before Microsoft Outlook ? Object Library
? is the Excel version number
 
Back
Top