ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   email from cells to outlook - code not working (https://www.excelbanter.com/excel-programming/337533-email-cells-outlook-code-not-working.html)

periro16[_3_]

email from cells to outlook - code not working
 

Code:
--------------------
.....
Email = ""
For Each cell In Sheets("Sheet1").Range("B1:B3")
Next cell
Email = WorksheetFunction.Substitute(Email, vbNewLine, "%0D%0A")
......
--------------------


WHen I run the code, I am not getting the email addresses put into the
'To' field in outlook. I dont know why its not picking up the email
addresses starting from B1 up to B3?? :confused: I am using a forloop
in the program so it runs three times


Many thnx
Peter


--
periro16
------------------------------------------------------------------------
periro16's Profile: http://www.excelforum.com/member.php...o&userid=26345
View this thread: http://www.excelforum.com/showthread...hreadid=396485


Ron de Bruin

email from cells to outlook - code not working
 
Hi Peter

See my site for examples
http://www.rondebruin.nl/sendmail.htm

Look also on the Outlook tips page


--
Regards Ron de Bruin
http://www.rondebruin.nl


"periro16" wrote in message
...

Code:
--------------------
.....
Email = ""
For Each cell In Sheets("Sheet1").Range("B1:B3")
Next cell
Email = WorksheetFunction.Substitute(Email, vbNewLine, "%0D%0A")
......
--------------------


WHen I run the code, I am not getting the email addresses put into the
'To' field in outlook. I dont know why its not picking up the email
addresses starting from B1 up to B3?? :confused: I am using a forloop
in the program so it runs three times


Many thnx
Peter


--
periro16
------------------------------------------------------------------------
periro16's Profile: http://www.excelforum.com/member.php...o&userid=26345
View this thread: http://www.excelforum.com/showthread...hreadid=396485




Ron de Bruin

email from cells to outlook - code not working
 
Hi periro16

Look on my site for examples
http://www.rondebruin.nl/sendmail.htm

If you want to mail to all E-mail addresses in column C use this code
instead of .To = "

Dim cell As Range
Dim strto As String
For Each cell In ThisWorkbook.Sheets("Sheet1") _
.Columns("C").Cells.SpecialCells(xlCellTypeConstan ts)
If cell.Value Like "*@*" Then
strto = strto & cell.Value & ";"
End If
Next
strto = Left(strto, Len(strto) - 1)

Change the To line to .To = strto



--
Regards Ron de Bruin
http://www.rondebruin.nl


"periro16" wrote in message
...

Code:
--------------------
.....
Email = ""
For Each cell In Sheets("Sheet1").Range("B1:B3")
Next cell
Email = WorksheetFunction.Substitute(Email, vbNewLine, "%0D%0A")
......
--------------------


WHen I run the code, I am not getting the email addresses put into the
'To' field in outlook. I dont know why its not picking up the email
addresses starting from B1 up to B3?? :confused: I am using a forloop
in the program so it runs three times


Many thnx
Peter


--
periro16
------------------------------------------------------------------------
periro16's Profile: http://www.excelforum.com/member.php...o&userid=26345
View this thread: http://www.excelforum.com/showthread...hreadid=396485





All times are GMT +1. The time now is 06:53 AM.

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