LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel Macro to email to addresses in "Contacts" Tab

I have a Workbook that gets updated periodically and when updated it need to
be emailed to a list of individuals. The list may change from time to time so
the email addresses for a given Workbook are listed on a separate tab, in
column A.

I want a macro to loop through the list, and add each address to the TO
field of the email. I have the following code which has two problems:
1. It creates a separate email for each address, and I want one email with
everyone on it.
2. The loop is looping through 20 rows, but the number of addresses may vary
from 1 or 2 to more than 20. What I want is for the macro to loop until it
hits a blank row and then stop. So users do not have to maintain the macro,
just the contacts tab.

Here's the code I have:
Sub EmailToContacts()
Dim olApp As Object, olMsg As Object, wb As Workbook, c As Range
Application.ScreenUpdating = False
Application.EnableEvents = False
Set olApp = CreateObject("Outlook.Application")
For Each c In Sheets("Contacts").Range("A1:A20")
Set olMsg = olApp.CreateItem(0)
With olMsg
.To = c.Value
.Subject = "This is a test" 'change as desired
.Body = "A Macro in Excel sent this using Emails in a tab
[Contacts]" 'change as desired
.Attachments.Add ThisWorkbook.FullName 'workbook must be saved
first
.Display 'change to .Send if you don't want displayed,
Redemption will be needed though
End With
Next c
Application.EnableEvents = True
Application.ScreenUpdating = True
Set olApp = Nothing
Set olMsg = Nothing
End Sub
 
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
Can't get email addresses to be "hot" when using lookup bsharp Excel Worksheet Functions 3 May 13th 09 02:30 PM
How to Link Excel to"Contacts" Folder Bob Levin Excel Discussion (Misc queries) 1 August 28th 07 11:32 AM
removing " marks from imported email addresses Outbacker Excel Discussion (Misc queries) 3 February 7th 07 04:52 PM
copy/convert column email addresses Hyperlink "mailto:" excel97 daleman101 Excel Discussion (Misc queries) 3 November 3rd 05 01:21 PM
Extracting email addresses from Outlook Contacts Todd Huttenstine[_2_] Excel Programming 3 January 12th 04 02:58 AM


All times are GMT +1. The time now is 03:57 PM.

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

About Us

"It's about Microsoft Excel"