Hi,
I'm using VS.Net 2005
and MS Access
I'm using the following code for sending email......
the problem is I've to extract email id's from database and put them in TO or CC field separated with comma when Page is loaded plz help me in this regard
// message elements
private string mMailServer;
private string mTo;
private string mFrom;
private string mMsg;
private string mSubject;
private string mCC;
private int mPort;
override protected void OnInit(EventArg s e)
{
base.OnInit(e);
btnSend.Click += new System.EventHan dler(btnSend_Cl ick);
}
private void MessageBox(stri ng strMsg)
{
Label lbl = new Label();
lbl.Text = "<script language='javas cript'>" + Environment.New Line + "window.ale rt(" + "'" + strMsg + "'" + ")</script>";
Page.Controls.A dd(lbl);
}
protected void btnSend_Click(o bject sender, System.EventArg s e)
{
string strMsg = null;
strMsg = txtMessage.Text ;
System.Data.Ole Db.OleDbConnect ion con = new System.Data.Ole Db.OleDbConnect ion("Provider=M icrosoft.Jet.Ol eDb.4.0;Data Source=c:/mms.mdb");
con.Open();
mTo = txtTo.Text.Trim (' ');
mFrom = txtFrom.Text.Tr im(' ');
mSubject = txtSubject.Text .Trim(' ');
mMsg = txtMessage.Text .Trim(' ');
mMailServer = ConfigurationMa nager.AppSettin gs.Get("localho st");
mPort = 25;
mCC = txtCC.Text.Trim (' ');
try
{
MailMessage message = new MailMessage(mFr om, mTo, mSubject, mMsg);
if (fileAttachment s.HasFile)
{
Attachment attached = new Attachment(file Attachments.Pos tedFile.FileNam e.ToString().Tr im(' '));
message.Attachm ents.Add(attach ed);
}
if (mCC != "" | mCC != string.Empty)
{
string[] strCC = mCC.Split(';');
foreach (string strThisCC in strCC)
{
message.CC.Add( strThisCC.Trim( ' '));
}
}
SmtpClient mySmtpClient = new SmtpClient(mMai lServer, mPort);
mySmtpClient.Us eDefaultCredent ials = true;
mySmtpClient.Se nd(message);
MessageBox("The mail message has been sent to " + message.To.ToSt ring());
}
catch (FormatExceptio n ex)
{
MessageBox("For mat Exception: " + ex.Message);
}
catch (SmtpException ex)
{
MessageBox("SMT P Exception: " + ex.Message);
}
catch (Exception ex)
{
MessageBox("Gen eral Exception: " + ex.Message);
}
} In PageLoad I'm currently using the following code
System.Data.Ole Db.OleDbConnect ion con;
System.Data.Ole Db.OleDbCommand cmd1;
System.Data.Ole Db.OleDbDataAda pter adap;
DataSet ds = new DataSet();
string sql = string.format(" select email from emp);
adap = new System.Data.Ole Db.OleDbDataAda pter(cmd);
for (I = 0; I < ds.Tables["emp"]. Rows.Count; I++)
{
txtTO.Text = ds.Tables["emp"]. Rows[i]["email"] + ",";
}
2 1637
Hi,
Are you getting any error?
Otherwise ,Your code seems to be ok.
You ,can check for the null value of email before this
txtTO.Text = ds.Tables["emp"]. Rows[i]["email"] + ",";.
Hi,
Are you getting any error?
Otherwise ,Your code seems to be ok.
You ,can check for the null value of email before this
txtTO.Text = ds.Tables["emp"]. Rows[i]["email"] + ",";.
Hi, I'm getting Object reference not set to an instance of an object. error in for loop
for (int I = 0; I < ds.Tables["emp"]. Rows.Count; I++)
{
txtTo.Text = ds.Tables["emp"]. Rows[i]["email"] + ",";
}
How to send email to my own system and see it ???
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alex Hunsley |
last post by:
I'm using the smtp module to send emails from python.
I would like to specify several recipients of the email like follows:
msg = MIMEText(time.ctime("Body text of email")
me = 'my@sending.address'
you = 'recipient1@some.where,recipient2@some.where'
msg = '*** Carwatch alert'
msg = me
msg = you
|
by: dnsstaiger |
last post by:
I try to accomplish the following:
I have two tables which are connected via a third table (N:N
relationship):
Table 1 "Locations"
LocationID (Primary Key)
Table 2 "Specialists"
SpecialistID (Primary Key)
|
by: Kris van der Mast |
last post by:
Hi,
I've created a little site for my sports club. In the root folder there are
pages that are viewable by every anonymous user but at a certain subfolder
my administration pages should be protected by forms authentication.
When I create forms authentication at root level it works but when I move my
code up to the subfolder I get this error:
Server Error in '/TestProjects/FormsAuthenticationTestingArea' Application.
|
by: Karen A Hodge |
last post by:
I have a website that has an Excel template. The template contains 3
QueryTables. The template is located on the web server. I would like to
refresh the data prior to the user opening the template from the website.
This is the code:
wb = excelApp.Workbooks.Add(FilePath)
wb.RefreshAll()
wb.Save()
excelApp.Quit()
.... User opens template
|
by: Tim::.. |
last post by:
Can someone please tell me why I keep being redirected back to the login page
even though I have logged in with the correct cridentials!!!
I have used this code before on another site and it works fine but when I
copied it across to the new site it stops working! All the variables are
passed when I do a debug but it just returns me to the login page again and
again!
Please help! It's driving me nuts!
| |
by: nate axtell |
last post by:
In VB .NET I load the contents of an Excel or comma seperated values file
into a dataGrid (via a datatable). One of the columns has a comma in the
name of the column. So for the comma separated values files I put double
quotes are the column name. What I see is that the name ends up getting
displayed correctly in the DataGrid column, "Class (1,2,3)". When I click
on the column to sort I see the following error:
"Additional information:...
|
by: genzy |
last post by:
I'm facing the below problem.
With <deny users="?" />, the Windows Login ID is able to be obtained to
fill up the Windows IDSID text field automatically, but reading the
file info is failed.
Without <deny users="?" />, the Windows Login ID is not able to be
obtained, but reading the file info is successful.
Is there any way to make both working at the same time?
|
by: mohdalibaig |
last post by:
the program woks fine for a single record but for multiple records it
isn't reading the entries properly...
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<graphics.h>
void read(void);
void write(void);
void main(void)
{
|
by: flavourofbru |
last post by:
Hi,
In the datagridview control, one of my column has multiple values separated by a comma
Is there a way to get individaual values which are separated by a comma from that particular cells?
Thanks in advance,
Brugu
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |