Asp.net 1.1 SMTP mail Sent email by system. Web. Mail. mailmessage inC # Handiz@hotmail.com ----------------------------------------------------- Public void Sendmail (string RECP, String title, string MSG) { // Define mail message System. Web. Mail. mailmessage mail = new system. Web. Mail. mailmessage (); Mail. To = RECP; Mail. From = system. configuration. configurationsettings. receivettings ["mailsender"]; Mail. Subject = title; Mail. Body = MSG; Mail. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); // Basic Authentication Mail. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); // your SMTP Username Mail. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password"); // your SMTP Password System. Web. Mail. smtpmail. smtpserver = "SMTP. Mail"; // your SMTP server address System. Web. Mail. smtpmail. Send (Mail ); } Asp.net 2.0 smtp mail: Date: 2006-11-08, title :( DOTNET) How to sent email fromC #2.0 (DOTNET) How to sent email from C # 2.0
Handiz@hotmail.com
------------------- Static public void Sendmail (string RECP, String title, string MSG) { // Sender String strfrom = system. configuration. configurationmanager. receivettings ["mailsender"];
// SMTP server password String strpass = system. configuration. configurationmanager. receivettings ["mailpassword"];
// Mail object System. net. Mail. mailmessage mail = new system. net. Mail. mailmessage (strfrom, RECP ); Mail. Subject = title; Mail. Body = MSG; Mail. isbodyhtml = true; Mail. bodyencoding = system. Text. encoding. utf8;
System. net. Mail. smtpclient = new system. net. Mail. smtpclient ();
// SMTP serveraddress Smtpclient. Host = system. configuration. configurationmanager. receivettings ["mailsmtp"]; Smtpclient. usedefadefacredentials = false; Smtpclient. Credentials = new system. net. networkcredential (strfrom, strpass ); // Smtpclient. deliverymethod = system. net. Mail. smtpdeliverymethod. Network; Smtpclient. Send (Mail ); } Merge/split TIF images: Title: generate multipage TIF and split multipage TIF inC # Generate multipage TIF and split multipage TIF in C #
MSN: handiz@hotmail.com Email: handiz@gmail.com ---------------- Using the tifprint. dll (Download at: http://www.diaries.cn/myworks/MSDotNet/Class/TifPrint/BIN/tifprint.zip)
// Split the multiple page tif file into single file Splittif (strfilename, strtargetfolder)
// Combine the files (can be JPG, BMP, Tif, PNG, GIF) into one multipage tif file Combinetif (string [] inputfilenames, string outputfilename)
---------------- /// <Summary> /// Combine some file into 1 TIF multipage File /// If black and write Image , We use ccitt4 Compression /// Else we use the LZW Compression /// </Summary> /// <Param name = "inputfilenames"> the files to be combined, canbe (BMP, JPG, GIF, PNG, Tif) </param> /// <Param name = "outputfilename"> the Output Filename </param> Public static void combinetif (string [] inputfilenames, string outputfilename) { // Get imagecodecinfo, generate Tif format Imagecodecinfo info = NULL; Foreach (imagecodecinfo ice in imagecodecinfo. getimageencoders ()) { If (ice. mimetype =" Image /Tiff ") { Info = ice; Break; } }
/* * Define the encoderparameter, * When the 1st page, will be encodervalue. multiframe. * When the other pages, will be encodervalue. framedimensionpage. * When all pages saved, will be the encodervalue. Flush. */
Encoderparameters Ep = new encoderparameters (2 );
/* * When the 1st file, 1st frame, will be true. * From the 1st file, 2nd frame, will be false. */ Bool B11 = true;
Image IMG = NULL;
// Create Image Instance from the 1stImage For (INT nloopfile = 0; nloopfile <inputfilenames. length; nloopfile ++) { // Get Image From SRC File Image Img_src = Image . Fromfile (inputfilenames [nloopfile]);
Guid = img_src.framedimensionslist [0]; System. Drawing. imaging. framedimension dimension = new System. Drawing. imaging. framedimension (guid );
// Get the frames from SRC File For (INT nloopframe = 0; nloopframe { Img_src.selectactiveframe (dimension, nloopframe );
/* * If black and write Image , We use ccitt4 Compression * Else we use the LZW Compression */ If (img_src.pixelformat = pixelformat. format1bppindexed) { Ep. Param [0] = new encoderparameter (encoder. compression, convert. toint32 (encodervalue. compressionccitt4 )); } Else { Ep. Param [0] = new encoderparameter (encoder. compression, convert. toint32 (encodervalue. compressionlzw )); }
If (B11) { // 1st file, 1st frame, create the master Image IMG = img_src;
Ep. Param [1] = new encoderparameter (encoder. saveflag, convert. toint32 (encodervalue. multiframe )); IMG. Save (outputfilename, info, EP );
B11 = false; Continue; }
Ep. Param [1] = new encoderparameter (encoder. saveflag, convert. toint32 (encodervalue. framedimensionpage )); IMG. Saveadd (Img_src, EP ); } } Ep. Param [1] = new encoderparameter (encoder. saveflag, convert. toint32 (encodervalue. Flush )); IMG. Saveadd (EP ); } ================================ Title :( DOTNET) how to split multiple page TIF to single file inC # (DOTNET) how to split multiple page TIF to single file in C #
Handiz@hotmail.com --------------------------------------------------------- // This function will split a tif file into sigle file, and put them // Into strtargerfolder. Public static void splittif (string strfilename, string strtargetfolder) { Image IMG = Image . Fromfile (strfilename ); Guid = IMG. framedimensionslist [0]; System. Drawing. imaging. framedimension dimension = new System. Drawing. imaging. framedimension (guid ); Int ntotframe = IMG. getframecount (dimension );
// Save all Frame Int nloop = 0; For (nloop = 0; nloop <ntotframe; nloop ++) { IMG. selectactiveframe (dimension, nloop ); IMG. Save (strtargetfolder + "\" + nloop. tostring () + ". tif ", System. Drawing. imaging. imageformat. Tiff ); } } Print TIF image: Title: 4 steps to print TIF in C #
4 steps to print TIF in C # handiz@hotmail.com -------------- using the tifprint. DLL (download at: http://www.diaries.cn/myworks/MSDotNet/Class/TifPrint/BIN/TifPrint.dll) // 1. create instance of tifprint tifprint TP = new tifprint (); // 2. add TIF files to printing list: TP. addFile (@ "C: \ 1.tif"); TP. addFile (@ "C: \ 2.tif"); ... // 3. show printing dialog or not TP. showdialog = true; // 4. print TP. print (); other functions: clearfile ()-Remove all files from printing list getpagecount () -Return the total page number of printing list splittif (strfilename, strtargetfolder)-split the multiple page tif file into single file
C #Save the webpage as an MHT File 1. Added com reference Microsoft CDO for Windows 2000 Library(C: \ windows \ system32 \ cdosys. dll) 2.Program: CDO. Message MSG = new CDO. messageclass (); CDO. Configuration CFG = new CDO. configurationclass ();
MSG. Configuration = CFG; MSG. createmhtmlbody("Http://www.sina.com.cn ",CDO. cdomhtmlflags. cdosuppressall ,"",""); MSG. getstream (). savetofile("C: \ A. MHT ",ADODB. saveoptionsenum. adsavecreateoverwrite );
|