Click here to Skip to main content
15,929,833 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: : How to use Ajax Pin
raushan_95-Jan-09 19:37
raushan_95-Jan-09 19:37 
GeneralRe: : How to use Ajax Pin
Denishce6-Jan-09 19:11
Denishce6-Jan-09 19:11 
AnswerRe: How to use Ajax Pin
N a v a n e e t h5-Jan-09 19:53
N a v a n e e t h5-Jan-09 19:53 
AnswerRe: How to use Ajax Pin
Abhijit Jana5-Jan-09 22:10
professionalAbhijit Jana5-Jan-09 22:10 
QuestionHow do remove or hide minimize,edit,close,delete buttons in webpart controls in .net? Pin
kathyani5-Jan-09 19:19
kathyani5-Jan-09 19:19 
AnswerRe: How do remove or hide minimize,edit,close,delete buttons in webpart controls in .net? Pin
Rajganesh Mountbatton5-Jan-09 19:24
Rajganesh Mountbatton5-Jan-09 19:24 
GeneralRe: How do remove or hide minimize,edit,close,delete buttons in webpart controls in .net? Pin
kathyani6-Jan-09 0:35
kathyani6-Jan-09 0:35 
Questionsending Emails problem Pin
NidhiKanu5-Jan-09 19:14
professionalNidhiKanu5-Jan-09 19:14 
Hi,


I am using gmail smtp for sending Emails and using this code :

// For sending Mail done by Nidhi on19sep08
public bool SendMail1(DataTable dt, string path)
{
string ToMail1 = "";
string UserName = "";
bool status = false;
int count = 0;
try
{
if (dt.Rows.Count > 1)
{
for (int i = 1; i <= dt.Rows.Count - 1; i++)
{

if (count == 0)
{
if (dt.Rows[0]["email"].ToString() != "")
{
ToMail1 = dt.Rows[0]["email"].ToString();
UserName = dt.Rows[0]["username"].ToString();
count = 1;
}
}
if (dt.Rows[i]["email"].ToString() != "")
{
ToMail1 = ToMail1 + "," + dt.Rows[i]["email"].ToString();
UserName = UserName + "," + dt.Rows[i]["username"].ToString();
}


}
}
else
{
if (dt.Rows.Count > 0)
{
if (dt.Rows[0]["email"].ToString() != "")
{
ToMail1 = dt.Rows[0]["email"].ToString();
UserName = dt.Rows[0]["username"].ToString();

}
}


}
if (dt.Rows.Count > 0)
{

bool mailSent = false;
SendMail objClsSendmail = new SendMail();
DataTable dtsmtpserver = objClsSendmail.getMailSetting();
int Port = Convert.ToInt32(dtsmtpserver.Rows[0][2].ToString());
string host = dtsmtpserver.Rows[0][1].ToString();
string User = dtsmtpserver.Rows[0][3].ToString();
string Password = dtsmtpserver.Rows[0][4].ToString();
MailAddress from = new MailAddress(dtsmtpserver.Rows[0][10].ToString());
MailAddress to = new MailAddress(ToMail1);
MailMessage msg = new MailMessage(from, to);

SqlConnection myConnection = new SqlConnection(SqlConnectionString.GetConnectionString());
SqlDataAdapter ad = new SqlDataAdapter("SELECT email FROM at_user where IsAdmin=1", myConnection);
DataTable ds = new DataTable();
ad.Fill(ds);
for (int k = 0; k <= ds.Rows.Count - 1; k++)
{
string[] id = ds.Rows[k][0].ToString().Split(',');

msg.CC.Add(id[0]);

}

string[] strUser = ToMail1.Split(',');
for (int j = 1; j < strUser.Length; j++)
{

msg.To.Add(strUser[j]);
}

if (path != "")
{
Attachment atcFile = new Attachment(path);
//***************Updated Code*********************
msg.Attachments.Add(atcFile);
}

// Subject
// msg.Subject = ddlProject.SelectedItem.Text.ToString()+"Post By" + Session["FirstName"].ToString() + " " + Session["LastName"].ToString();
msg.Subject = ddlProject.SelectedItem.Text.ToString() + " : " + ddlSubject.SelectedItem.Text + " (" + Session["FirstName"].ToString() + " " + Session["LastName"].ToString() + " )";
// Html message body
msg.IsBodyHtml = true;
msg.Body="<html><head> <title>Communication</title>";
// msg.Body=msg.Body+" color: #0A246A; padding:10px 0px 10px 10px;} .Regards{ font-weight: bold;color: #0A246A;";
// msg.Body=msg.Body+" padding:10px 0px 10px 10px; } a {color:#0077bd;} td {font-size: 14px; } </style>";
msg.Body=msg.Body+"</head><body > <table cellpadding='0' cellspacing='0' align='left' style='FONT-SIZE: 11px; FONT-FAMILY: Arial;width:800px; >";
msg.Body=msg.Body+"<tr><td rowspan='2' width='10'></td><td></td> </tr> ";
msg.Body=msg.Body+"<tr><td><table cellpadding='0' cellspacing='0' width='100%'>";
msg.Body = msg.Body + "<tr><td colspan='2'><p>";
//msg.Body = msg.Body + "<tr><td colspan='2'><div class=salute>Dear " + UserName + ",<p>";
msg.Body=msg.Body+ txtMessage.Value+"</p> </td> </tr>";
msg.Body = msg.Body + "<tr rowspan='2'><td></br></br><div> <div> Posted by</div> ";
msg.Body=msg.Body+"<div>"+Session["FirstName"].ToString() + " " + Session["LastName"].ToString();
msg.Body=msg.Body+" on "+ System.DateTime.Now.ToString()+"</div> </div> </td></tr> ";
msg.Body=msg.Body+ "</table></td></tr></table></body></html>";


//assigning Priority
msg.Priority = MailPriority.High;






SmtpClient client = new SmtpClient(host, Port);//
//client.UseDefaultCredentials = false;
client.EnableSsl = true;
// System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("excellent", "m49q3r");
System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential(User, Password);
client.Credentials = theCredential;
Console.WriteLine("Sending an e-mail message to {0} by using the SMTP host{1}.", to.Address, client.Host);
client.Send(msg);//Sending the mail..


}
status = true;



//**********************************************************
}
catch (Exception ex)
{

status = false;
return status;
throw ex;
}
finally { }
return status;
}





I am using this xml for getting detail about SMTP setting

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<MailSetting id="mailSettingInfo">
<Smtpauthenticate>1</Smtpauthenticate>
<SmtpServer>smtp.gmail.com</SmtpServer>
<SmtpPort>587</SmtpPort>
<Sendusername>abc@gmail.com</Sendusername>
<Sendpassword>123</Sendpassword>
<ProxcyServer />
<ProxcyUser />
<ProxcyPassword />
<ProxcyPort />
<ProxcyAuthenticate />
<FromMailID>xyz@gmail.com</FromMailID>
</MailSetting>


Now there is no problem in sending mail but there is one problem that when mail limit exceed its limit(perhaps it is 500/day) then it block sending mail for 24 hours.

Do any one have other idea to do this.

Thanx in advance
Answer: sending Emails problem Pin
Jas 0075-Jan-09 19:31
Jas 0075-Jan-09 19:31 
GeneralRe: : sending Emails problem Pin
NidhiKanu5-Jan-09 19:37
professionalNidhiKanu5-Jan-09 19:37 
General: sending Emails problem Pin
Jas 0075-Jan-09 19:42
Jas 0075-Jan-09 19:42 
GeneralRe: : sending Emails problem Pin
NidhiKanu5-Jan-09 19:49
professionalNidhiKanu5-Jan-09 19:49 
General[Message Deleted] Pin
Jas 0075-Jan-09 19:52
Jas 0075-Jan-09 19:52 
GeneralRe: sending Emails problem Pin
Jas 0075-Jan-09 19:52
Jas 0075-Jan-09 19:52 
Questionneed help urgent (how to done connectivity with database) Pin
Jas 0075-Jan-09 18:50
Jas 0075-Jan-09 18:50 
AnswerRe: need help urgent (how to done connectivity with database) Pin
Abhijit Jana5-Jan-09 19:01
professionalAbhijit Jana5-Jan-09 19:01 
Generalneed help urgent (how to done connectivity with database) Pin
Jas 0075-Jan-09 19:23
Jas 0075-Jan-09 19:23 
AnswerRe: need help urgent (how to done connectivity with database) Pin
raushan_95-Jan-09 19:15
raushan_95-Jan-09 19:15 
GeneralRe: need help urgent (how to done connectivity with database) Pin
Jas 0075-Jan-09 19:22
Jas 0075-Jan-09 19:22 
AnswerRe: need help urgent (how to done connectivity with database) Pin
NidhiKanu5-Jan-09 19:26
professionalNidhiKanu5-Jan-09 19:26 
Generalneed help urgent (how to done connectivity with database) Pin
Jas 0075-Jan-09 19:35
Jas 0075-Jan-09 19:35 
GeneralRe: need help urgent (how to done connectivity with database) Pin
NidhiKanu5-Jan-09 19:44
professionalNidhiKanu5-Jan-09 19:44 
Generalneed help urgent (how to done connectivity with database) Pin
Jas 0075-Jan-09 19:46
Jas 0075-Jan-09 19:46 
GeneralRe: need help urgent (how to done connectivity with database) Pin
NidhiKanu5-Jan-09 19:56
professionalNidhiKanu5-Jan-09 19:56 
QuestionPreview Image after FileUpload button clicked, but without writing to a File and using a URL Pin
Ryan Neil Shaw5-Jan-09 11:42
Ryan Neil Shaw5-Jan-09 11:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.