Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Send Mail in Excel Spreadsheet with fields in spreadsheet

Dear Experts,
Regarding this topic, I have read following path. That's rally useful.

http://www.rondebruin.nl/sendmail.htm

I have tested following scripts. That's work.
Now I want to have something changed.

Please imagine following as a spreadsheet.
Row/Column

A B C D
E F
_|________________________________________________ ________________
1| Marco Buttons Send to CC List BCC List Subject
Body Text
2| RUN-Client A Testing
Hello,Test
3| Run-Income
Income Stmt Pls
note $

I want to set a list of buttons in Column A, then send the Excel files as
attachment to recipients based on the text I typed in Column B. (I can add,
modify / delete easily from now on if it is succeeded). Also, can I use comma
, or ; to separate the recipients if they are more than one please ?
Activate the Excel windows (file has been opened) and send that file should
not be a problem. I can manage the scripts. Just want to send to the people
based on the text in a cell only.

CC list and BCC list are in Column C and D respectively (if any).
Column E is meant for Subject of the mail.
F is a Simple Body text for the mail.

The final part is that ... Is it possible to put in MS outlook 2003 Draft
first please ?
(I can re-check before I really press the send button in MS outlook.)
If possible, can you tell the scripts for Send and the scripts to be Draft
as well ?

Please apologize if it is too complicated. Thanks for help!

(Quote)
Sub Mail_Workbook_2()
'Working in 2000-2007
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String

Set wb1 = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" &
vbNewLine & _
"be no VBA code in the file you send. Save the" &
vbNewLine & _
"file first as xlsm and then try the macro again.",
vbInformation
Exit Sub
End If
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy
h-mm-ss")
FileExtStr = "." & LCase(Right(wb1.Name, _
Len(wb1.Name) - InStrRev(wb1.Name, ".", ,
1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)

With wb2
On Error Resume Next
.SendMail ", _
"This is the Subject line"
On Error GoTo 0
.Close SaveChanges:=False
End With

'Delete the file
Kill TempFilePath & TempFileName & FileExtStr

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
(End of Quote)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Send Mail in Excel Spreadsheet with fields in spreadsheet

Hi all,
I dont know why after uploading ... it becomes so ugly.

Anyway, column A is a list of marco buttons.
Cells in Column B contains the Email address for recipents.
Cells in Column C contains the Email address in CC list.
Cells in Column D contains the Email address for BCC list.
Cells in Column E contains the Email address for Mail Subject.
Cells in Column F contains the Email address for Body Text for the mail.

Thanks,

"Elton Law" wrote:

Dear Experts,
Regarding this topic, I have read following path. That's really useful.

http://www.rondebruin.nl/sendmail.htm

I have tested following scripts. That's work.
Now I want to have something changed.

Please imagine following as a spreadsheet.
Row/Column

A B C D
E F
_|________________________________________________ ________________
1| Marco Buttons Send to CC List BCC List Subject
Body Text
2| RUN-Client A Testing
Hello,Test
3| Run-Income
Income Stmt Pls
note $

I want to set a list of buttons in Column A, then send the Excel files as
attachment to recipients based on the text I typed in Column B. (I can add,
modify / delete easily from now on if it is succeeded). Also, can I use comma
, or ; to separate the recipients if they are more than one please ?
Activate the Excel windows (file has been opened) and send that file should
not be a problem. I can manage the scripts. Just want to send to the people
based on the text in a cell only.

CC list and BCC list are in Column C and D respectively (if any).
Column E is meant for Subject of the mail.
F is a Simple Body text for the mail.

The final part is that ... Is it possible to put in MS outlook 2003 Draft
first please ?
(I can re-check before I really press the send button in MS outlook.)
If possible, can you tell the scripts for Send and the scripts to be Draft
as well ?

Please apologize if it is too complicated. Thanks for help!

(Quote)
Sub Mail_Workbook_2()
'Working in 2000-2007
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String

Set wb1 = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" &
vbNewLine & _
"be no VBA code in the file you send. Save the" &
vbNewLine & _
"file first as xlsm and then try the macro again.",
vbInformation
Exit Sub
End If
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy
h-mm-ss")
FileExtStr = "." & LCase(Right(wb1.Name, _
Len(wb1.Name) - InStrRev(wb1.Name, ".", ,
1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)

With wb2
On Error Resume Next
.SendMail ", _
"This is the Subject line"
On Error GoTo 0
.Close SaveChanges:=False
End With

'Delete the file
Kill TempFilePath & TempFileName & FileExtStr

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
(End of Quote)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Send Mail in Excel Spreadsheet with fields in spreadsheet

Hi Elton

Start with the Outlook mail template
http://www.rondebruin.nl/mail/templates.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Elton Law" wrote in message ...
Dear Experts,
Regarding this topic, I have read following path. That's rally useful.

http://www.rondebruin.nl/sendmail.htm

I have tested following scripts. That's work.
Now I want to have something changed.

Please imagine following as a spreadsheet.
Row/Column

A B C D
E F
_|________________________________________________ ________________
1| Marco Buttons Send to CC List BCC List Subject
Body Text
2| RUN-Client A Testing
Hello,Test
3| Run-Income
Income Stmt Pls
note $

I want to set a list of buttons in Column A, then send the Excel files as
attachment to recipients based on the text I typed in Column B. (I can add,
modify / delete easily from now on if it is succeeded). Also, can I use comma
, or ; to separate the recipients if they are more than one please ?
Activate the Excel windows (file has been opened) and send that file should
not be a problem. I can manage the scripts. Just want to send to the people
based on the text in a cell only.

CC list and BCC list are in Column C and D respectively (if any).
Column E is meant for Subject of the mail.
F is a Simple Body text for the mail.

The final part is that ... Is it possible to put in MS outlook 2003 Draft
first please ?
(I can re-check before I really press the send button in MS outlook.)
If possible, can you tell the scripts for Send and the scripts to be Draft
as well ?

Please apologize if it is too complicated. Thanks for help!

(Quote)
Sub Mail_Workbook_2()
'Working in 2000-2007
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String

Set wb1 = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" &
vbNewLine & _
"be no VBA code in the file you send. Save the" &
vbNewLine & _
"file first as xlsm and then try the macro again.",
vbInformation
Exit Sub
End If
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy
h-mm-ss")
FileExtStr = "." & LCase(Right(wb1.Name, _
Len(wb1.Name) - InStrRev(wb1.Name, ".", ,
1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)

With wb2
On Error Resume Next
.SendMail ", _
"This is the Subject line"
On Error GoTo 0
.Close SaveChanges:=False
End With

'Delete the file
Kill TempFilePath & TempFileName & FileExtStr

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
(End of Quote)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Send Mail in Excel Spreadsheet with fields in spreadsheet

That's fantastic ... I will have a try ... let you know the outcome later.
At least I can see the sunrise !

"Ron de Bruin" wrote:

Hi Elton

Start with the Outlook mail template
http://www.rondebruin.nl/mail/templates.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Elton Law" wrote in message ...
Dear Experts,
Regarding this topic, I have read following path. That's rally useful.

http://www.rondebruin.nl/sendmail.htm

I have tested following scripts. That's work.
Now I want to have something changed.

Please imagine following as a spreadsheet.
Row/Column

A B C D
E F
_|________________________________________________ ________________
1| Marco Buttons Send to CC List BCC List Subject
Body Text
2| RUN-Client A Testing
Hello,Test
3| Run-Income
Income Stmt Pls
note $

I want to set a list of buttons in Column A, then send the Excel files as
attachment to recipients based on the text I typed in Column B. (I can add,
modify / delete easily from now on if it is succeeded). Also, can I use comma
, or ; to separate the recipients if they are more than one please ?
Activate the Excel windows (file has been opened) and send that file should
not be a problem. I can manage the scripts. Just want to send to the people
based on the text in a cell only.

CC list and BCC list are in Column C and D respectively (if any).
Column E is meant for Subject of the mail.
F is a Simple Body text for the mail.

The final part is that ... Is it possible to put in MS outlook 2003 Draft
first please ?
(I can re-check before I really press the send button in MS outlook.)
If possible, can you tell the scripts for Send and the scripts to be Draft
as well ?

Please apologize if it is too complicated. Thanks for help!

(Quote)
Sub Mail_Workbook_2()
'Working in 2000-2007
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String

Set wb1 = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" &
vbNewLine & _
"be no VBA code in the file you send. Save the" &
vbNewLine & _
"file first as xlsm and then try the macro again.",
vbInformation
Exit Sub
End If
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy
h-mm-ss")
FileExtStr = "." & LCase(Right(wb1.Name, _
Len(wb1.Name) - InStrRev(wb1.Name, ".", ,
1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)

With wb2
On Error Resume Next
.SendMail ", _
"This is the Subject line"
On Error GoTo 0
.Close SaveChanges:=False
End With

'Delete the file
Kill TempFilePath & TempFileName & FileExtStr

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
(End of Quote)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I do an e-mail mail merge using an Excel spreadsheet? Gretchen Excel Worksheet Functions 0 July 19th 09 05:18 PM
why can't i send my excel spreadsheet? perplexed Excel Worksheet Functions 1 February 19th 06 06:45 AM
When I send a spreadsheet via e-mail they see it differently? LeslieV Excel Discussion (Misc queries) 3 July 28th 05 05:14 PM
How can I send an e-mail including data from a spreadsheet? jcfv Excel Discussion (Misc queries) 5 June 15th 05 06:13 AM
Send link to Excel spreadsheet jennyfarrell Excel Programming 2 May 7th 04 12:02 AM


All times are GMT +1. The time now is 04:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"