AddExtra.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:2k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Globalization ;
- using System.Net ;
- using System.IO ;
- using System.Collections ;
- namespace MailSend
- {
- /// <summary>
- /// AddExtra 的摘要说明。
- /// </summary>
- public class AddExtra
- {
- public AddExtra()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- private string []Attachment;
- /// <summary>
- /// 重载的构造函数,以便把相关的附件信息传入
- /// </summary>
- /// <param name="array"></param>
- public AddExtra(ArrayList array)
- {
- Attachment=new string [array.Count ];
- for(int i=0;i<array.Count ;i++)
- {
- Attachment[i]=array[i].ToString ();
- }
- }
- /// <summary>
- /// 获得当前时间
- /// </summary>
- /// <returns></returns>
- public string GetTime()
- {
- string time=DateTime.Now .ToString ("F",DateTimeFormatInfo.InvariantInfo );
- return time;
- }
- /// <summary>
- /// 获得本机名
- /// </summary>
- /// <returns></returns>
- public string GetName()
- {
- string cpuName=Dns.GetHostName ();
- return cpuName;
- }
- /// <summary>
- /// 获得本机IP地址
- /// </summary>
- /// <returns></returns>
- public string[] GetIP()
- {
- IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
- string []ipAddress=new string [addressList.Length ];
- for(int i=0;i<ipAddress.Length ;i++)
- {
- ipAddress[i]=addressList[i].ToString ();
- }
- return ipAddress;
- }
- /// <summary>
- /// 保存信件
- /// </summary>
- /// <param name="fileName">要保存为的文件名</param>
- /// <param name="Text">要保存的信件内容</param>
- public void SaveLetter(string fileName,string Text)
- {
- StreamWriter sw=new StreamWriter (fileName,true);
- sw.WriteLine (Text);
- if(Attachment.Length !=0)
- {
- sw.WriteLine("此封邮件的附件的路径如下:");
- }
- else
- {
- sw.Write ("此封邮件没有附件!");
- }
- for(int i=0;i<Attachment.Length ;i++)
- {
- sw.WriteLine(Attachment[i]);
- }
- sw.Flush ();
- sw.Close ();
- }
- }
- }