一
發送請求
/// <summary>
/// 發送請求
/// </summary>
/// <param name=
/// <param name=
/// <param name=
/// <returns>返回的結果</returns>
public static string RequestUrl(string url
{
try
{
HttpWebRequest hwrq = null;
if (method ==
{
hwrq = (HttpWebRequest)HttpWebRequest
hwrq
hwrq
//hwrq
hwrq
byte[] postData = System
hwrq
hwrq
Stream writeStream = hwrq
writeStream
writeStream
}
else if (method ==
{
hwrq = (HttpWebRequest)HttpWebRequest
hwrq
//hwrq
hwrq
}
if (hwrq != null)
{
HttpWebResponse hwrp = (HttpWebResponse)hwrq
//return hwrp
StreamReader sr = new StreamReader(hwrp
return sr
}
}
catch (Exception ex)
{
throw ex;
}
return null;
}
二
郵件發送
/// <summary>
/// 發送郵件
/// </summary>
/// <param name=
/// <param name=
/// <param name=
/// <param name=
/// <param name=
/// <param name=
/// <param name=
/// <returns>成功與否</returns>
public static bool SendSMTPEMail(string strSmtpServer
{
System
System
try
{
client = new SmtpClient();
client
client
client
//星號改成自己郵箱的密碼
client
message = new MailMessage(strFrom
message
message
message
message
//添加附件
foreach (string forStr in Attachments)
{
Attachment data = new Attachment(forStr
message
}
client
}
catch (Exception ex)
{
using (System
{
sw
}
return false;
}
finally
{
if (message != null)
{
foreach (Attachment forData in message
forData
message
message
}
}
return true;
}
From:http://tw.wingwit.com/Article/program/net/201311/11601.html