C#操作TIF文件
ASP.NET 1.1 SMTP发邮件
发送电子邮件由System.Web.Mail.MailMessage中 C#
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.AppSettings["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开邮件:
日期:2006-11-08,题目:如何发送电子邮件的C# 2.0 (DOTNET)
(DOTNET) 从 C # 2.0中发送电子邮件
handiz@hotmail.com
-------------------
handiz@hotmail.com
-------------------
static public void SendMail(string recp, string title, string msg)
{
//sender
string strFrom = System.Configuration.ConfigurationManager.AppSettings["MailSender"];
//smtp server password
string strPass = System.Configuration.ConfigurationManager.AppSettings["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 smtpClient = new System.Net.Mail.SmtpClient();
//smtp serveraddress
smtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["MailSmtp"];
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(strFrom, strPass);
//smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Send(mail);
}
合并/分割TIF图片:
标题:生成多页TIF和分割多页TIF ç#
生成多页TIF和分割多页TIF在C#中
的MSN:handiz@hotmail.com
电子邮件:handiz@gmail.com
----------------
使用的TifPrint.dll
(下载:HTTP: / / www.diaries.cn / myworks / MSDotNet /类/ TifPrint /宾/ tifprint.zip的)
/ /单一文件分成多页TIF文件
SplitTif(strFilename,strTargetFolder)
/ /合并的文件(可以是JPG,BMP ,TIF,PNG,GIF)到一个多页TIF文件
CombineTif(字符串[] InputFilenames的字符串OutputFileName参数)
----------------
/ / / <summary>的
/ / /合并一些文件到1 TIF多页的文件
/ / /如果黑色和写入
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 a image instance from the 1st image
for (int nLoopfile = 0; nLoopfile < InputFilenames.Length; nLoopfile ++)
{
//get image from src file
Image img_src = Image.FromFile(InputFilenames[nLoopfile]);
Guid 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.GetFrameCount(dimension); 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);
}
====================
标题:(DOTNET)如何分割多页TIF到单个文件C#
(DOTNET)如何分割多页TIF文件单C#
handiz@hotmail.com
------------------------------- --------------------------
/ /此函数将分裂成事务所文件TIF文件,并把它们
/ /将strTargerFolder。
public static void SplitTIF(string strFilename, string strTargetFolder)
{
Image img = Image.FromFile(strFilename);
Guid 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);
}
}
打印TIF图片:
标题:4个步骤打印TIF ç#
4个步骤打印TIF在C#
使用的TifPrint.dll
(下载:http://www.diaries.cn/myworks/MSDotNet
handiz@hotmail.com
---------------- TifPrint /类/ /宾/ TifPrint.dll)
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#的将网页保存为MHT文件
1. 增加 COM Reference
Microsoft CDO for Windows 2000 Library (C:\WINDOWS\System32\cdosys.dll)
2. 程序:
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);