delphi Indy控件可以实现exchange发邮件吗

zhaisp 2016-09-19 01:41:38
如题,现在可以实现POP3模式发邮件,但收到的邮件在exchange模式先是乱码,手工调整邮件编码也不行,求大神指导,如何实现exchange模式发送邮件
...全文
305 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaisp 2016-09-21
  • 打赏
  • 举报
回复
引用 2 楼 lyhoo163 的回复:
通过TIdSMTP,可以发。编码大致如下:
var TM:TIdMessage;
    S1,S2,S3:string;
begin
  TM:=TIDMEssage.Create(nil);
  With TM do
  begin
    Body.Assign(Memo22.Lines);
    From.address   := Combobox23.Text;             // 发件人地址
    Recipients.EMailAddresses:=Combobox28.Text;    // 收件人地址,这里改为你的EMAIL地址
    Subject:=Combobox29.Text;                      // 邮件标题
    Priority:=TIDMessagePriority(Combobox26.ItemIndex);
    if Edit21.text<>'' then                        // 附件1
      if FileExists(Edit21.Text) then
         TIdAttachment.Create(MessageParts,Edit21.Text);
    Edit22.Text:=Trim(Edit22.Text);                // 附件2
    if Edit22.text<>'' then
      if FileExists(Edit22.Text) then
         TIdAttachment.Create(MessageParts,Edit22.Text);
    Edit23.Text:=Trim(Edit23.Text);               // 附件3
    if Edit23.text<>'' then
      if FileExists(Edit23.Text) then
         TIdAttachment.Create(MessageParts,Edit23.Text);
  end;
  case Combobox27.ItemIndex of
    0 : IdSMTP1.AuthenticationType:=atLogin;      // 需要认证
    1 : IdSMTP1.AuthenticationType:=atNone;       // 无需认证
  end;
  IdSMTP1.Username := Combobox23.text;            // 服务器上的用户名
  IdSMTP1.Password := Edit25.text;                // 服务器上的密码
  IdSMTP1.Host := Combobox21.text;                // 服务器SMTP地址
  IdSMTP1.Port := StrToInt(Combobox22.text);      // 服务器端口
  try
    IdSMTP1.Connect;
  except
    statusbar1.Panels[0].text:=IntToStr(List)+'、无法连接到服务器!';
    exit;
  end;
现在是不加附件可以正常发送接收 加上附件就乱码了...
zhaisp 2016-09-21
  • 打赏
  • 举报
回复
引用 2 楼 lyhoo163 的回复:
通过TIdSMTP,可以发。编码大致如下:
var TM:TIdMessage;
    S1,S2,S3:string;
begin
  TM:=TIDMEssage.Create(nil);
  With TM do
  begin
    Body.Assign(Memo22.Lines);
    From.address   := Combobox23.Text;             // 发件人地址
    Recipients.EMailAddresses:=Combobox28.Text;    // 收件人地址,这里改为你的EMAIL地址
    Subject:=Combobox29.Text;                      // 邮件标题
    Priority:=TIDMessagePriority(Combobox26.ItemIndex);
    if Edit21.text<>'' then                        // 附件1
      if FileExists(Edit21.Text) then
         TIdAttachment.Create(MessageParts,Edit21.Text);
    Edit22.Text:=Trim(Edit22.Text);                // 附件2
    if Edit22.text<>'' then
      if FileExists(Edit22.Text) then
         TIdAttachment.Create(MessageParts,Edit22.Text);
    Edit23.Text:=Trim(Edit23.Text);               // 附件3
    if Edit23.text<>'' then
      if FileExists(Edit23.Text) then
         TIdAttachment.Create(MessageParts,Edit23.Text);
  end;
  case Combobox27.ItemIndex of
    0 : IdSMTP1.AuthenticationType:=atLogin;      // 需要认证
    1 : IdSMTP1.AuthenticationType:=atNone;       // 无需认证
  end;
  IdSMTP1.Username := Combobox23.text;            // 服务器上的用户名
  IdSMTP1.Password := Edit25.text;                // 服务器上的密码
  IdSMTP1.Host := Combobox21.text;                // 服务器SMTP地址
  IdSMTP1.Port := StrToInt(Combobox22.text);      // 服务器端口
  try
    IdSMTP1.Connect;
  except
    statusbar1.Panels[0].text:=IntToStr(List)+'、无法连接到服务器!';
    exit;
  end;
这种方式好像跟POP3没什么区别呀
lyhoo163 2016-09-20
  • 打赏
  • 举报
回复
通过TIdSMTP,可以发。编码大致如下:
var TM:TIdMessage;
    S1,S2,S3:string;
begin
  TM:=TIDMEssage.Create(nil);
  With TM do
  begin
    Body.Assign(Memo22.Lines);
    From.address   := Combobox23.Text;             // 发件人地址
    Recipients.EMailAddresses:=Combobox28.Text;    // 收件人地址,这里改为你的EMAIL地址
    Subject:=Combobox29.Text;                      // 邮件标题
    Priority:=TIDMessagePriority(Combobox26.ItemIndex);
    if Edit21.text<>'' then                        // 附件1
      if FileExists(Edit21.Text) then
         TIdAttachment.Create(MessageParts,Edit21.Text);
    Edit22.Text:=Trim(Edit22.Text);                // 附件2
    if Edit22.text<>'' then
      if FileExists(Edit22.Text) then
         TIdAttachment.Create(MessageParts,Edit22.Text);
    Edit23.Text:=Trim(Edit23.Text);               // 附件3
    if Edit23.text<>'' then
      if FileExists(Edit23.Text) then
         TIdAttachment.Create(MessageParts,Edit23.Text);
  end;
  case Combobox27.ItemIndex of
    0 : IdSMTP1.AuthenticationType:=atLogin;      // 需要认证
    1 : IdSMTP1.AuthenticationType:=atNone;       // 无需认证
  end;
  IdSMTP1.Username := Combobox23.text;            // 服务器上的用户名
  IdSMTP1.Password := Edit25.text;                // 服务器上的密码
  IdSMTP1.Host := Combobox21.text;                // 服务器SMTP地址
  IdSMTP1.Port := StrToInt(Combobox22.text);      // 服务器端口
  try
    IdSMTP1.Connect;
  except
    statusbar1.Panels[0].text:=IntToStr(List)+'、无法连接到服务器!';
    exit;
  end;
jjpweb 2016-09-19
  • 打赏
  • 举报
回复
可以。。。。。。。。。。。。。TIdSMTP;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧