ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Email code (https://www.excelbanter.com/excel-worksheet-functions/231655-email-code.html)

ozhunter

Email code
 
I have the following VBA code that works, but I would like to avoid having to
click the OE message box that asks if you want to send the email when you run
the code. I was also wondering if you can specify text for the body of the
email, not something that changes all the time, it will be the same text each
time.

Sheets("Pay Slip").Visible = True
Sheets("Pay Slip").Select
Sheets("Pay Slip").Copy
Range("A1:G17").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("a1").Select
ActiveWorkbook.SendMail ", Subject:="Pay
Slip for Adam Brown - Claim No 16420EML"
ActiveWorkbook.Close SaveChanges:=False
Sheets("Pay Slip").Select
Sheets("Pay Slip").Visible = False


End Sub

Any help would be appreciated

Jacob Skaria

Email code
 
Use the outlook object..

Refer the below link for help
http://www.rondebruin.nl/mail/folder2/mail1.htm
--
If this post helps click Yes
---------------
Jacob Skaria


"ozhunter" wrote:

I have the following VBA code that works, but I would like to avoid having to
click the OE message box that asks if you want to send the email when you run
the code. I was also wondering if you can specify text for the body of the
email, not something that changes all the time, it will be the same text each
time.

Sheets("Pay Slip").Visible = True
Sheets("Pay Slip").Select
Sheets("Pay Slip").Copy
Range("A1:G17").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("a1").Select
ActiveWorkbook.SendMail ", Subject:="Pay
Slip for Adam Brown - Claim No 16420EML"
ActiveWorkbook.Close SaveChanges:=False
Sheets("Pay Slip").Select
Sheets("Pay Slip").Visible = False


End Sub

Any help would be appreciated



All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com