Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Macro for Email - Sending to email addresses in cell

Hello,

I have reviewed Ron de Bruin's website
(http://www.rondebruin.nl/sendmail.htm) and used his code to create a macro
to send email from Excel. I would like to add/edit code so I can send email
To: email addresses located in cell O3 of worksheet name "Intx"

Please kindly advise. Macro details below.


Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'You can also use a range if you want
Set rng = Sheets("Payment
Intx").Range("$N$9:$O$18").SpecialCells(xlCellType Visible)
On Error GoTo 0

If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

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

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Wire Intx"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send as replacement to auto-send email without
review
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro for Email - Sending to email addresses in cell

Hi Brice

See the tips page
http://www.rondebruin.nl/mail/tips2.htm

--

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


"Brice" wrote in message ...
Hello,

I have reviewed Ron de Bruin's website
(http://www.rondebruin.nl/sendmail.htm) and used his code to create a macro
to send email from Excel. I would like to add/edit code so I can send email
To: email addresses located in cell O3 of worksheet name "Intx"

Please kindly advise. Macro details below.


Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'You can also use a range if you want
Set rng = Sheets("Payment
Intx").Range("$N$9:$O$18").SpecialCells(xlCellType Visible)
On Error GoTo 0

If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

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

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Wire Intx"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send as replacement to auto-send email without
review
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Email - Sending to email addresses in cell


Replace
Code:
--------------------

On Error Resume Next
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Wire Intx"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send as replacement to auto-send email without
review
End With

--------------------
with
Code:
--------------------

On Error Resume Next
With OutMail
.To = "
.CC = Sheets("Intx").Range("O3").Value
.BCC = ""
.Subject = "Wire Intx"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send as replacement to auto-send email without
review
End With

--------------------
Brice;198314 Wrote:
Hello,

I have reviewed Ron de Bruin's website
('Example Code for sending mail from Excel'
(http://www.rondebruin.nl/sendmail.htm)) and used his code to create a
macro
to send email from Excel. I would like to add/edit code so I can send
email
To: email addresses located in cell O3 of worksheet name "Intx"

Please kindly advise. Macro details below.



Code:
--------------------
Sub Mail_Selection_Range_Outlook_Body()

' Don't forget to copy the function RangetoHTML in the module.
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
'You can also use a range if you want
Set rng = Sheets("Payment
Intx").Range("$N$9:$O$18").SpecialCells(xlCellType Visible)
On Error GoTo 0

If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If

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

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "Wire Intx"
.HTMLBody = RangetoHTML(rng)
.Display 'or use .Send as replacement to auto-send email without
review
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

--------------------



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=54603

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
Using Macro how to create email link for the email addresses in aRange or Selection Satish[_2_] Excel Worksheet Functions 8 December 28th 09 03:30 PM
can I copy a column of email addresses, paste into email address? Lizizfree New Users to Excel 4 July 20th 06 10:03 PM
Sending email to addresses in a column starguy Excel Discussion (Misc queries) 2 June 30th 06 09:55 PM
Email addresses in Excel need to format for mass email Boomer Excel Worksheet Functions 1 June 9th 06 01:46 PM
Transfer Email addresses from spreadsheet to email address book Beana Excel Discussion (Misc queries) 2 May 30th 06 06:07 PM


All times are GMT +1. The time now is 01:22 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"