Hi, I'm new to this site. It looks great. Sounds like you all have lots of experience.
I'm a primary school class representative and I want to create an excel contact list of the parents email addresses so that I can click a button, it will open the default email (in my case MS Outlook) and then populate the "To" email address field with the email addresses (separated by a comma).
Can anyone provide me the VB code that I can paste into my worksheet VBA that will look at a range of cells (say E2:E30) that contain email addresses, and put them in the "To" field of a blank email?
I have put a button on the page and it's called "EmailButton" but I don't know what VB to put with it. I'm using MSExcel 2007 (at home) and 2003 (at work)
Thanks
Last edited by The Flightless Kiwi; 04-06-2009 at 06:42 PM.
Hi,
Welcome to the forum, take a look at Ron de Bruin's site here
http://www.rondebruin.nl/sendmail.htm
oldchippy
-------------
![]()
![]()
If you are happy with the help you have received, please click the blue scales icon in the blue bar of the post.
Click here >>> Top Excel links for beginners to Experts
Forum Rules >>>Please don't forget to read these
I found that the fiorst example on this link was the closest http://www.rondebruin.nl/mail/folder3/message.htm The only change I did was remove the ".Send" and change to ".Display" so I could edit the email prior to sending. This works great for heaps of emails that get sent one at a time. I want a group type email.
If I want to bring up ONE blank email with all the recipients in the "To" field. And the recipient email addresses were all contained in a range (Say E2:E30), what would I need to midify for the above code to work?
Thanks again - I'm nearly there
Hi,
On the link in your post, there is this other link, hopefully that will help?
Check out this page for Tips If you want to change the code on this page.
http://www.rondebruin.nl/mail/tips2.htm
oldchippy
-------------
![]()
![]()
If you are happy with the help you have received, please click the blue scales icon in the blue bar of the post.
Click here >>> Top Excel links for beginners to Experts
Forum Rules >>>Please don't forget to read these
SOLVED - Thank you old chippy!
This works a treat. Here's the finished code. It's not tidy as it's a mish mash of bits but it works!!
Sub EmailGroup()
Dim cell As Range
Dim strto As String
For Each cell In ThisWorkbook.Sheets("Sheet1").Range("B2:B100")
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"
End If
Next cell
If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = strto
.Subject = "Enter subject here"
.Body = "" ' EMPTY FOR NOW
'USE THIS FOR ENTERING NAMES OF RECIPIENTS IN BODY TEXT "here"
'"Dear" & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Enter body text " & _
"here"
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
'.Send 'Or use Display
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
![]()
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
oldchippy
-------------
![]()
![]()
If you are happy with the help you have received, please click the blue scales icon in the blue bar of the post.
Click here >>> Top Excel links for beginners to Experts
Forum Rules >>>Please don't forget to read these
Is there a way to make that work with gmail?
tate2133,
Your post does not comply with Rule 2 of our Forum RULES.
Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
You have a thread open on this topic, please stick to it.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks