解决方案 »

  1.   

    具体发送邮件代码如下:
      with IdMsgSend do
      begin
        Body.Clear;
        Body.Add('测试内容!');
        From.Text := g_EMailAddress;
        Recipients.EMailAddresses := g_ReceiveEMail;        // To: header 客户经理EMail
        Subject := g_EMailSubjectInfo;                      // Subject: header 邮件主题
        Priority := TIdMessagePriority(g_SendPriority);     // Message Priority 邮件发送等级
        CCList.EMailAddresses := g_EMailAddress;            // CC 抄送
        BccList.EMailAddresses := '';                       // BBC 密送
        if g_ReturnReciept=1 then
        begin //We set the recipient to the From E-Mail address
          ReceiptRecipient.Text := From.Text;
        end
        else
        begin //indicate that there is no receipt recipiant
          ReceiptRecipient.Text := '';
        end;
      end;
      case g_SMTPLoginType of
        0: SMTP.AuthenticationType := atNone;
        1: SMTP.AuthenticationType := atLogin; //Simple Login
      end;
      SMTP.Username := g_SMTPUserName;
      SMTP.Password := g_SMTPUserPWD;  {General setup}
      SMTP.Host := g_SMTPServer;
      SMTP.Port := g_SMTPPort;  {now we send the message}
      try
        SMTP.Connect;
      except
        Result := False;
      end;
      try
        try
          SMTP.Send(IdMsgSend);
        except
          Result := False;
        end;
      finally
        SMTP.Disconnect;
      end;