Solved

visual basic + excel - sending emails to mulitple address stored in cells

Posted on 2003-10-22
3
590 Views
Last Modified: 2010-04-17
hey

once again more problems sending emails using visual basic (though a different program this time)

the guitarist in my band wants an easy to use mailing list. now there are plently of eaier options for doing this.. but i decided to try writing one using VB and Excel, just to see if i could really...

... i cant! or at least, im having trouble, hense the reason im here!

basically email addresses are stored in the individual cells of a column (range("a1") downwards)

at the moment, im using this code, kindly suggest by Bruintje in one of my previous questions to send the emails:

Dim iOutlook As Object
Dim myApp As Object
Set iOutlook = CreateObject("Outlook.Application")
Set myApp = iOutlook.CreateItem(0)
myApp.To = (blank)
myApp.Subject = "My Subject"
'myApp.Attachments.Add "C:\file.txt" '<-uncomment to attach a file
myApp.Body = "ello"
'myApp.send
Set myApp = Nothing
Set iOutlook = Nothing
End Sub

however, i want to know if it is possible to have the email sent to all the addresses stored in the column. i can do the address in the first cell of the column:

yApp.To = range("a1").value

but i havnt got a clue how to go about getting other email address into the "yApp.To" section.

is it possible? can the experts understand my crude explanation of my problem? will toast ever fall butter side up? only time will tell :)

thanks,

dave xXxx
0
Comment
Question by:paddock
3 Comments
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9603290
if you know exactly how many email in the column then

yApp.To = range("a1").value & ";" & range("a2").value & ";" & range("a3") & ... continue here
0
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 125 total points
ID: 9603909
Dim x as string
int i as integer

i = 0
while Cells(i, "A").Value <> Empty
 x = x + Cells(i,"A").Value +"; "
Wend

myApp.To = x

note: It runs until there's a blank, but I would figure you had the list sorted.  I would also recommend doing the myApp.BCC to eliminate publishing everyone's e-mail addresses to each other.  Good luck!
0
 

Author Comment

by:paddock
ID: 9605313
thankee most kindly sir!

doesnt quite work, but i think thats my own inadequacies showing through lol

il keep working on it, it does look like exactly what i need!

as for your suggestion fantasy1001, although that would have worked, there are two problems:

1) the number of people on the list are always changing (people subscribe, unsubscribe) and seeing how the recipicant of the program knows less VB than myself, he wouldnt know how to adjust the code accordingly

2) there is absolutly no way that im going to sit there and type out all the cell refrences! i really am that lazy:)

but thank you for your advice

dave xXxx
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now