接收与发送邮件(XE10.2+WIN764)
千万不要用QQ邮箱测试,我试了半天,没整明白。
一、设置信息
POP3接收邮件
POP3服务器:exchange.grandsoft.com.cn
端口:110
账号:zhujq-a@glodon.com
密码:123456789
你的Email:zhujq-a@glodon.com
SMTP发送邮件
SMTP服务器:exchange.grandsoft.com.cn
端口:25
类型:satDefault
账号:zhujq-a
密码:123456789
uses
IdAttachmentFile,//引入
procedure TForm1.Button1Click(Sender: TObject);
begin
IdSMTP1.Host := 'exchange.grandsoft.com.cn';
IdSMTP1.Port := 25;
IdSMTP1.username := 'zhujq-a';//发送者用户名
IdSMTP1.password := '123456789';//密码用自己的
IdSMTP1.AuthType := satDefault;
IdSMTP1.Connect;//连接
idmessage1.CharSet := 'gb2312';// 这句不能解决乱码的问题
// IdMessage1.ContentType := 'text/html'; //要增加附件就不能打开这个,要不然好像是用流发送
IdMessage1.From.address := 'zhujq-a@glodon.com'; // 发件人地址
IdMessage1.Recipients.EMailAddresses := '513187410@qq.com'; // 收信人地址
IdMessage1.Subject := '标题1'; // 邮件标题
IdMessage1.Priority := mphigh;//优先级
IdMessage1.Body.Text := '内容1';//邮件内容
TIdAttachmentFile.Create(IdMessage1.MessageParts, 'e:\123.txt');//添加附件
try
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1);
finally
IdSMTP1.Disconnect;
end;
end;
===============D7=========================
procedure TForm1.Button1Click(Sender: TObject);
begin
IdSMTP1:= TIdSMTP.Create(nil);
IdSMTP1.AuthenticationType := atLogin;
IdSMTP1.Host := 'smtp.163.com';
IdSMTP1.Username := '****************'; //用户名
IdSMTP1.Password := '**************'; //密码
IdMessage1:= TIdMessage.Create(nil);
IdMessage1.Recipients.EMailAddresses := 'zhujianqiangqq@163.com'; //收件人地址(多于一个的话用逗号隔开)
IdMessage1.From.Text := 'zhujianqiangqq@163.com'; //自己的邮箱地址
IdMessage1.Subject := 'test'; //邮件标题
idMessage1.priority:=mphigh; //优先级,mphigh为最高级
IdMessage1.Body.Text := RichEdit1.Text; //邮件内容
TIdAttachment.Create(IdMessage1.MessageParts, 'f:\软件图.jpg'); //添加附件
try
IdSMTP1.Connect();
try
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1);
ShowMessage('发送成功');
except
ShowMessage('邮件发送失败');
end;
except
ShowMessage('无法连接邮件服务器!');
end;
IdSMTP1.Disconnect;
end;
相关文章
- MSP430的CAN通信发送
- 【主机】发送邮件脚本的改进
- Python应用-完成简单邮件发送功能
- 使用java底层实现邮件的发送(含测试,源码)
- postman发送post请求
- java发送邮件无法显示图片 图裂 的解决办法
- Linux SendMail发送邮件失败诊断案例(二)
- C# 调用 Outlook发送邮件实例
- linux(centos8):prometheus使用alertmanager发送报警邮件(prometheus 2.18.1/alertmanager 0.20.0)
- linux利用sendmail发送邮件的方法
- linux发送邮件使用外部邮箱
- 发送xml报文去第三方请求获取xml报文数据
- java 发送邮件实例
- vue.js3:用mitt发送接收事件消息(vue@3.2.6 / mitt@3.0.0)
- spring boot:用rocketmq发送延时消息用来取消订单(spring boot 2.3.3)
- linux(centos8):prometheus使用alertmanager发送报警邮件(prometheus 2.18.1/alertmanager 0.20.0)
- linux利用sendmail发送邮件的方法
- spring boot发送普通文本邮件/HTML邮件/附件邮件/图片邮件完整代码
- GCM 发送接收消息 Message Client Server 服务器端,客户端
- crontab任务取消发送邮件
- 干货 | 解放双手,用Python实现自动发送邮件
- java发送邮件时遇到的坑
- Java 发送邮件
- Python 自动发送邮件实战案例,人人都可以学会
- Nodejs 发送邮件
- c# 向驱动打印机发送命令打开钱箱
- Drupal 7 电子邮件的发送设置 SMTP, Mail System, Mime Mail
- 3.python 发送邮件之smtplib模块
- 哪一个对象可以用于获得浏览器发送的请求。
- python实战===使用smtp发送邮件的源代码,解决554错误码的问题,更新版!
- Laravel自带SMTP邮件组件实现发送邮件(QQ、163、企业邮箱都可)
- 【项目实战】基于定时任务框架XXL-JOB实现定时每天发送周年祝福人员
- SCI实现多字节发送
- ASP.NET(Web网站开发),简单邮件发送的制作