473,395 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Sending email (recipients)

B
Follow-up to my original post.

Is it possible for the "objEmail.To" to lookup the values from a sqlserver
table?

At the moment, I type the email address separated by a semi-colon.

TIA~

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "se**@test.com"
objEmail.To = "re*****@test.com"
objEmail.Subject = "TEST SUBJECT"
objEmail.AddAttachment "\\server\test.csv"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserver") = "SERVER_NAME"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusername") = "username"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendpassword") = "userpwd"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

set objEmail = nothing
Jun 29 '06 #1
1 1379
> Is it possible for the "objEmail.To" to lookup the values from a sqlserver
table?
No, but you can easily lookup the values in your script to build the
objEmail.To string. Below is an untested example:

Set connection = CreateObject("ADODB.Connection")
connection.Open "Provider=SQLOLEDB" & _
";Data Source=MyServer" & _
";Initial Catalog=MyDatabase" & _
";Integrated Security=SSPI"
Set emailAddressRs = _
connection.Execute("SELECT eMailAddress FROM dbo.Contacts")
recipientList = ""
Do While emailAddressRs.EOF = False
If recipientList = "" Then
recipientList = emailAddressRs.Fields(0).Value
Else
recipientList = recipientList & _
";" & emailAddressRs.Fields(0).Value
End If
emailAddressRs.MoveNext
Loop
emailAddressRs.Close
connection.Close

objEmail.To = recipientList

--
Hope this helps.

Dan Guzman
SQL Server MVP

"B" <no_spam@no_spam.com> wrote in message
news:_Z******************************@rcn.net... Follow-up to my original post.

Is it possible for the "objEmail.To" to lookup the values from a sqlserver
table?

At the moment, I type the email address separated by a semi-colon.

TIA~

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "se**@test.com"
objEmail.To = "re*****@test.com"
objEmail.Subject = "TEST SUBJECT"
objEmail.AddAttachment "\\server\test.csv"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserver") = "SERVER_NAME"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendusername") = "username"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/sendpassword") = "userpwd"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configu
ration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

set objEmail = nothing

Jun 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe | last post by:
Hi, I am sending an email from an asp page. Besides sending an email to sender, I am sending myself a BCC also. Out of 100 emails sent, about 5 recipients received a blank email (no text in...
1
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is...
1
by: John Smith | last post by:
Hi, I'm trying to send email in our C# ASP.Net application using the Outlook 11 library. For a bunch of unimportant reasons (unimportant to this posting that is) we have to do it this way and...
2
by: ReidarT | last post by:
I have some code for sending email. The problem is, I need to send an email to 3 persons and CC to 2 persons. When I try to code email1@mail.com;email2@mail.com I get an error. I have tried this...
4
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time...
5
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
0
by: Jim Devenish | last post by:
I wish to send a copy of an email to a selected number of recipients. I can do this when the email contains only text but have a problem when the email contains a picture. I create a new email...
1
by: handokowidjaja | last post by:
Hi All, Several weeks ago i started a topic with the same subject, however the solutions provided was for using MS Outlook (fullblown version). I finally found something that works directly with...
0
by: damimkader | last post by:
Hi, I'm trying to send emails using a Macro based on an Excel Sheet and the Email Client I'm using is Lotus Notes. OS used - Windows Xp. Language - VB Below is the Code I'm using for doing...
31
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.