Send Email from Excel

L

lehainam

Dear all,

I have a macro to mail many sheets as belows:

Sub Mail_every_Worksheet()

'Mail every Worksheet with address in cell B4 using VBA in Microsoft
Excel

'Dim strDate As String
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("B4").Value Like "*@*" And sh.Name <> "Form" Then
sh.Copy
'strDate = Format(Date, "dd-mm-yy") & " " & Format(Time,
"h-mm-ss")
ActiveWorkbook.SaveAs sh.Name & ".xls"
ActiveWorkbook.SendMail ActiveSheet.Range("B4").Value, _
ActiveSheet.Name
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
End If
Next sh
Application.ScreenUpdating = True
End Sub

However, I don't know how to put the content of this email, for ex.
"This is the salary of Jun 05".

Could any one can help me to add the content to my email.

Thanks a lot!

Nam
 
S

Snake Plissken

It depends on mail system installed on ur machine because u need to create
reference to library...
As far as I know excel doesn't support "e.g .body" method.
 
I

iainking

lehainam said:
Dear all,

I have a macro to mail many sheets as belows:

Sub Mail_every_Worksheet()

'Mail every Worksheet with address in cell B4 using VBA in Microsoft
Excel

'Dim strDate As String
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("B4").Value Like "*@*" And sh.Name <> "Form" Then
sh.Copy
'strDate = Format(Date, "dd-mm-yy") & " " & Format(Time,
"h-mm-ss")
ActiveWorkbook.SaveAs sh.Name & ".xls"
ActiveWorkbook.SendMail ActiveSheet.Range("B4").Value, _
ActiveSheet.Name
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
End If
Next sh
Application.ScreenUpdating = True
End Sub

However, I don't know how to put the content of this email, for ex.
"This is the salary of Jun 05".

Could any one can help me to add the content to my email.

Thanks a lot!

Nam

There's another thread that might help:
http://groups-beta.google.com/group...amming/browse_thread/thread/6ab21d1eb90af0f1/


Iain
 

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