栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

用sendcloud来发邮件(标题不能少于十个汉字)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

用sendcloud来发邮件(标题不能少于十个汉字)

平时发验证码邮件都是用免费域名邮箱,但是有时一频繁发多了就发不了了,听说用sendcloud可以避免,还能避免阿里云邮件发QQ邮箱进垃圾箱中,去注册了下,免费账户号每个月才50封,自己玩玩可以吧。。

收费的话一个月59,1万封以内的,不知道行不行。。先看看吧。。

下面是封装好的代码,那个api_user和api_key进网页里设置就好了

    
public static string SendMailBySendCloud(String from, String to, String title, String content, string api_user = "niuna?????", string api_key = "v2?????")
{
String url = "http://api.sendcloud.net/apiv2/mail/send";
HttpClient client = null;
HttpResponseMessage response = null;
string result;

    try
    {

 client = new HttpClient();

 List> paramList = new List>();

 paramList.Add(new KeyValuePair("apiUser", api_user));
 paramList.Add(new KeyValuePair("apiKey", api_key));
 paramList.Add(new KeyValuePair("from", from));
 paramList.Add(new KeyValuePair("fromName", from));
 paramList.Add(new KeyValuePair("to", to));
 paramList.Add(new KeyValuePair("subject", title));
 paramList.Add(new KeyValuePair("html", content));

 response = client.PostAsync(url, new FormUrlEncodedContent(paramList)).Result;
 result = response.Content.ReadAsStringAsync().Result;
 //Console.WriteLine(result);
    }
    catch (Exception e)
    {
 result = e.Message;
 Console.WriteLine("nException Caught!");
 Console.WriteLine("Message :{0} ", e.Message);
    }
    finally
    {
 if (null != client)
 {
     client.Dispose();
 }
    }

    return result;
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/231698.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号