C # mass mailing

Source: Internet
Author: User
Tags mailmessage
String nowdsn = configurationsettings. deleettings ["data"];
Sqlconnection myconnection = new sqlconnection (nowdsn );
Sqldataadapter mycommand1 = new sqldataadapter ("select * from vendor order by vendor DESC", myconnection );
Dataset ds1 = new dataset ();
Mycommand1.fill (ds1, "vendor ");
DR1 = ds1.tables ["vendor"]. Rows [0];
Int dscount = ds1.tables ["vendor"]. Rows. count;
// -----------------------------------------------------
For (INT I1 = 0; I1 <dscount; I1 ++)
{
Sqldataadapter mycommand11 = new sqldataadapter ("select * from PUR where (purchaser = 'lily' or purchaser = 'wang xiaome ') and status = '0' and email_caption = '0' and status3 = '1' and vendor = '"+ ds1.tables [" vendor "]. rows [I1] ["vendor"]. tostring () + "'", myconnection );
Dataset ds11 = new dataset ();
Mycommand11.fill (ds11, "pur ");
If (ds11.tables ["pur"]. Rows. Count> 0)
{
Dr11 = ds11.tables ["pur"]. Rows [0];
Int dscount11 = ds11.tables ["pur"]. Rows. count;
For (INT i11 = 0; i11 <dscount11; i11 ++)
{
Body1 = body1 + "<Table border = 1 bgcolor = e2f9ff> <tr> <TD width = 100>" + ds11.tables ["pur"]. rows [i11] ["Pono"]. tostring () + "</TD> <TD width = 120>" + ds11.tables ["pur"]. rows [i11] ["part"]. tostring () + "</TD> <TD width = 350>" + ds11.tables ["pur"]. rows [i11] ["Specification"]. tostring () + "</TD> <TD width = 100>" + ds11.tables ["pur"]. rows [i11] ["precdate"]. tostring () + "</TD> <TD width = 100>" + ds11.tables ["pur"]. rows [i11] ["QTY"]. tostring () + "</TD> <TD width = 100>" + ds11.tables ["pur"]. rows [i11] ["vendor"]. tostring () + "</TD> </tr> </table>" + "\ r \ n ";
Sum1 = sum1 + 1;
Sum11 = sum11 + 1;
Subject1 = ds11.tables ["pur"]. Rows [i11] ["vendor"]. tostring ();
//-------------------------------------------------------------------
String commandtext;
Sqlcommand mycommand111 = new sqlcommand ();
Mycommand111.connection = myconnection;
Mycommand111.connection. open ();
Mycommand111.commandtext = "Update pur set email_caption = '1' where p_id = '" + ds11.tables ["pur"]. rows [i11] ["p_id"]. tostring () + "'";
Mycommand111.executenonquery ();
Mycommand111.connection. Close (); // if it is sent once, the email will not be sent again after the field email_caption is changed to 1.
//-------------------------------------------------------------------
}

Smtpmail. smtpserver = "mail.lw-org.com ";
Mailmessage omessage = new mailmessage ();
Omessage. bodyformat = mailformat. html;
Omessage. Priority = mailpriority. High;
Omessage. From = "jianfeng-luo@lw-org.com ";
Omessage. To = ds1.tables ["vendor"]. Rows [I1] ["email"]. tostring ();
Omessage. bcc = "li-yang@longwaycorp.com.cn; qingmei-wang@longwaycorp.com.cn ";
// Omessage. bcc = "jianfeng-luo@lw-org.com" + ds1.tables ["vendor"]. Rows [I1] ["email2"]. tostring ();
Omessage. bodyencoding = encoding. utf8;
Omessage. Subject = "" + subject1;
Omessage. body = "" + datetime. now. date. toshortdatestring () + "returns the following message: "+" \ r \ n "+ sum1 +" new ticket "+" \ r \ n "+" <br/> <Table border = 1 bgcolor = 718bd6> <tr> <TD width = 100> "+" "+" </TD> <TD width = 120> "+" "+" </TD> <TD width = 350> "+" expected name "+" </TD> <TD width = 100> "+" Expected date "+" </TD> <TD width = 100> "+" data volume "+" </TD> <TD width = 100> "+" supplier "+" </TD> </tr> </table> "+ body1;
Smtpmail. Send (omessage );
Response. Write ("OK! ");
Response. Write ("<font color = 'blue'> ");
Response. Write (ds1.tables ["vendor"]. Rows [I1] ["vendor"]. tostring ());
Response. Write (ds1.tables ["vendor"]. Rows [I1] ["email"]. tostring ());
Response. Write (ds1.tables ["vendor"]. Rows [I1] ["ven_name"]. tostring ());
Response. Write ("</font> ");
Response. Write (sum1 + "NOTE" + body1 );
Response. Write ("<br/> ");
}
Body1 = "";
Sum1 = 0;
}
Response. Write ("<font color = 'red'> ");
Response. Write (" li" + sum11 );
Response. Write ("new ticket ");
Response. Write ("</font> ");
Response. Write ("<br/> ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.