|
|
导航: |
论坛 -> 移动应用开发
斑竹:flyers,iamdream |
|
作者: |
ywo (ywo) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2019/1/7 14:05:42 |
标题: |
|
加入我的收藏 |
楼主: |
我用的是delphi xe 10.2,在电脑上用以下代码发送邮件正常,主题和正文的中文字都没有乱码,但在安卓上发送邮件,主题中文变成?????,正文正常,没有乱码,不知道哪里有问题,各位高手帮忙看看,谢谢了!
用的是自带的Indy10控件.
procedure TForm1.Button1Click(Sender: TObject); begin IdSMTP1.Host := 'smtp.sina.com'; IdSMTP1.Port := 25; IdSMTP1.username := 'xxxx@sina.com'; //发送者用户名 IdSMTP1.password := 'xxxxxxxxx'; //密码用自己的 IdSMTP1.AuthType := satDefault; IdSMTP1.Connect; //连接
IdMessage1.Clear; idmessage1.CharSet := 'gb2312'; // 这句不能解决乱码的问题 IdMessage1.Encoding := meDefault; IdMessage1.From.address := 'xxxx@sina.com'; // 发件人地址 IdMessage1.Recipients.EMailAddresses := 'xxxxxxxxxx'; // 收信人地址 IdMessage1.Subject := '测试'; // 邮件标题 IdMessage1.Priority := mphigh; //优先级 IdMessage1.Body.Text := '这是一封测试邮件'; //邮件内容 try IdSMTP1.Send(IdMessage1); finally IdSMTP1.Disconnect; end; ShowMessage('发送完毕!'); end;
----------------------------------------------
- |
作者: |
|
2019/1/7 19:29:43 |
1楼: |
这个你要用android的代码发送
----------------------------------------------
-
|
作者: |
ywo (ywo) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2019/1/8 9:29:32 |
2楼: |
能给出代码吗?谢谢了
----------------------------------------------
-
|
作者: |
|
2019/1/8 14:29:04 |
3楼: |
百度吧,还是用 Intent 发送,很简单的,类似调用call打电话一样
----------------------------------------------
-
|
作者: |
ywo (ywo) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2019/1/8 15:33:34 |
3楼: |
问题解决了!只要这里改一下就行,也不用Android的代码,只用Indy的代码.
IdMessage1.Subject := ''; // 邮件标题 IdMessage1.ExtraHeaders.Values['Subject'] := EncodeHeader(UTF8Encode('测试'), '', 'Q', 'UTF-8');
结贴了.
----------------------------------------------
-
|
作者: |
|
2019/1/8 18:15:56 |
4楼: |
EncodeHeader 在哪哦?
----------------------------------------------
http://www.cnblogs.com/tulater/
|
作者: |
|
2019/1/8 18:37:46 |
5楼: |
@tulater uses Idcoderheader;
----------------------------------------------
-
|
作者: |
|
2019/1/8 19:04:27 |
6楼: |
@wg961423 谢谢你哦
----------------------------------------------
http://www.cnblogs.com/tulater/
|
作者: |
vga (vga) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2019/1/9 5:49:52 |
7楼: |
为 ywo 点赞
----------------------------------------------
-
|
|