利用email.net设置网络代理发邮件
来源:互联网 发布:沈阳速达软件 编辑:程序博客网 时间:2024/05/16 05:59
最近在做一个项目,客户的内部网络需要设置代理才能收发邮件,本来一个简单的东西突然变得复杂了,在baidu搜索了很久都没找到适合的组件,baidu就像个废物一样,没办法只能去yahoo搜,结果在微软的组件网站上找到了email.net,地址是:http://visualstudiogallery.msdn.microsoft.com/28b96cd4-b755-48a0-b686-9abb7d5607a8, 这个网站还可以找到很多不错的关于.net的组件,C#开发者可以多上上。
通过代理发邮件的代码如下:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Email.Net.Common;using Email.Net.Common.Collections;using Email.Net.Common.Configurations;using Email.Net.Smtp;namespace ProxyUsageDemo{public partial class Demo : Form{public Demo(){InitializeComponent();proxyType.Items.AddRange(new object [] {EProxyType.No, EProxyType.SOCKS5, EProxyType.SOCKS4});proxyType.DropDownStyle = ComboBoxStyle.DropDownList;proxyType.SelectedIndex = 1;proxyType.Refresh();}private void sendMessage_Click(object sender, EventArgs e){//Create and send message using proxy//SMTP client settings//URL of host to connect totarget.Host = hostBox.Text;//TCP port for connectiontarget.Port = (ushort)portNum.Value;//Username to login to the SMTP servertarget.Username = loginBox.Text;//Password to login to the SMTP servertarget.Password = passwordBox.Text;//Configure proxytarget.ProxyType = (EProxyType)proxyType.SelectedItem;target.ProxyHost = proxyHostBox.Text;target.ProxyPort =(ushort) proxyPortNum.Value;target.ProxyUser = proxyUserBox.Text;target.ProxyPassword = proxyPasswordBox.Text;//Create address and message EmailAddressCollection addressCollection = new EmailAddressCollection();addressCollection.Add(new EmailAddress(toBox.Text));//Create messageSmtpMessage message = new SmtpMessage(new EmailAddress(fromBox.Text),//Source addressaddressCollection,//Address of the recipientsubjectBox.Text,//Message subjectmessageBox.Text //Message text);SendResult result = target.SendOne(message);//Send messageif (result.IsSuccessful){MessageBox.Show("Message sent successful!");}else{MessageBox.Show("Message sending failed!");}}}}
0 0
- 利用email.net设置网络代理发邮件
- 利用CodeIgniter中的Email类发邮件
- C#发邮件 利用SmtpClient 发邮件 .net发邮件
- java Email 发邮件
- 【Django】 发邮件 email
- PHP 发邮件email
- [VB.NET源码]简单的EMAIL发邮件程序
- 使用commons-email发邮件
- 使用commons-email发邮件
- 使用commons-email发邮件
- perl Email::Sender 发邮件
- .NET 发送EMAIL邮件
- 使用.NET发送邮件 发送邮件,发邮件,EMail,SMTPMAIL,asp.net 选择自 kwklover 的 Blog
- java中利用commons-email-1.2.jar实现简单的发邮件
- 利用发邮件
- 利用SQLServer发邮件
- 利用smtp发邮件
- 利用smtp发邮件
- Android开发EditText属性
- 23个设计模式的简明教程_转载JOBBOLE
- Apache Maven 入门篇(下)
- Ubuntu下 Eclipse菜单栏消失
- 转SQL Server 的事务和锁
- 利用email.net设置网络代理发邮件
- MySQL语句之describe,explain,help,use
- AJAX基础实例
- Excel实现上传 导入 解析Excel 页面展示Excel数据
- 使用JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过了为 maxJsonLength属性
- 怎样为Linux内核打补丁,及特定版本内核下载
- 【JAVA】 关于int 以及String的转换
- 在ubuntu上配置xunsearch全文搜索引擎
- VS制作程序安装包