Solved

TSMTP and TMIME

Posted on 1998-08-13
6
319 Views
Last Modified: 2010-04-03
Hello everyone.

I am using now Mailer Program with TSMTP and TMIME components.
But two troubles occurred.

1: [fatal error] cannot send a mail.
2: 'JST' time zone is needed, but 'PST' time zone is written in header.
   I cannot understand how to change the 'time zone' in TMIME component.

I read the TNEW help file but it is difficult to understand.

A part of my code is following.
-------------------------------------------------
function NoParam: Variant;
begin
  TVarData(Result).VType := varError;
  TVarData(Result).VError := DISP_E_PARAMNOTFOUND;
end;

//--------------------------
//procedure to send a mail
//--------------------------
procedure TForm1.btnSendClick(Sender: TObject);
var
  sAttachedFileName: String;
  path: String;
  oleResultFileName: OleVariant;

begin
  MIME1.Headers.Clear;
  MIME1.Headers.Add('From', '...From_Address...' );
  MIME1.Headers.Add('To', '...To_Address...');
  MIME1.Headers.Add('Subject', '...Subject...');
  MIME1.Body := '...contents...';

  path := ExtractFilePath(ParamStr(0));
  sAttachedFileName := path + '...a Attached File Name...';
  MIME1.OleObject.Attachments.Append(sAttachedFileName,'Attached File',icTextPlain,,,);

  SMTP1.DocInput.PushStreamMode := True;

  oleResultFileName := path + 'result.txt';
  MIME1.Compose(oleResultFileName);
end;

//------------------------
//procedure to connect
//------------------------
procedure TForm1.btnConnectClick(Sender: TObject);
begin
  if SMTP1.State = prcConnected then
  begin
   SMTP1.Quit;
   btnConnect.Caption := 'Connect';
  end
  else if SMTP1.State = prcDisconnected then
  begin
   SMTP1.RemoteHost := '...the SMTP server name...';
   SMTP1.Connect(NoParam, NoParam);
  end;

end;

//-----------------------------
//SMTP1DocInput event handler
//-----------------------------
procedure TForm1.SMTP1DocInput(Sender: TObject; const DocInput: DocInput);
begin
  case DocInput.State of
    icDocBegin:
      StatusBar.SimpleText := 'Initiating document transfer';
    icDocHeaders:
      StatusBar.SimpleText := 'Sending headers';
    icDocData:
      if DocInput.BytesTotal > 0 then
        StatusBar.SimpleText := Format('Sending data: %d of %d bytes (%d%%)',
          [Trunc(DocInput.BytesTransferred), Trunc(DocInput.BytesTotal),
           Trunc(DocInput.BytesTransferred/DocInput.BytesTotal*100)])
      else
        StatusBar.SimpleText := 'Sending...';
    icDocEnd:
        tatusBar.SimpleText := Format('Mail sent to %s (%d bytes data)', ['iryou@mta.biglobe.ne.jp',          Trunc(DocInput.BytesTransferred)]);
  end;
  StatusBar.Update;
end;

//----------------------------------
//SMTP1StateChanged event handler
//----------------------------------
procedure TForm1.SMTP1StateChanged(Sender: TObject; State: Smallint);
begin
  InSendMethod := False;
  case State of
    prcConnecting:
      StatusBar.SimpleText := 'Connecting to SMTP server: '+SMTP1.RemoteHost+'...';
    prcResolvingHost:
      StatusBar.SimpleText := 'Resolving Host';
    prcHostResolved:
      StatusBar.SimpleText := 'Host Resolved';
    prcConnected:
      begin
        StatusBar.SimpleText := 'Connected to SMTP server: '+SMTP1.RemoteHost;
        InSendMethod := True;
      end;
    prcDisconnecting:
      StatusBar.SimpleText := 'Disconnecting from SMTP server: '+SMTP1.RemoteHost+'...';
    prcDisconnected:
      begin
        StatusBar.SimpleText := 'Disconnected from SMTP server: '+SMTP1.RemoteHost;
      end;
   end;
end;

//------------------------------
//MIME1DocOutput event handler
//------------------------------
procedure TForm1.MIME1DocOutput(Sender: TObject;const DocOutput: DocOutput);
var
  Name, Value: WideString;
  i: integer;
  buf: OleVariant;
begin
  if InSendMethod = True then
  begin
    if DocOutput.state = icDocBegin then
      SMTP1.DocInput.PushStream
    else if DocOutput.state = icDocHeaders then
    begin
      SMTP1.DocInput.Headers.Clear;
      For i:=1 to DocOutput.Headers.Count do
      begin
        Name:=DocOutput.Headers.item(i).Name;
        Value:=DocOutput.Headers.item(i).Value;
        SMTP1.DocInput.Headers.Add(Name, Value);
      end;
      SMTP1.DocInput.PushStream;
    end
    else if DocOutput.state = icDocData then
    begin
      DocOutput.GetData(buf, NoParam);
      SMTP1.DocInput.SetData(buf);
      SMTP1.DocInput.PushStream;
    end
    else if DocOutput.state = icDocEnd then
    begin
      SMTP1.DocInput.PushStream;
    end
    else if DocOutput.state = icDocError then
      InSendMethod := False;
  end;
end;
------------------------------------------------------

Thanks for your advice.

Sakya
0
Comment
Question by:sakya
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362032
sakya,

sorry can't help you with this one. Had to much bugs in the components of delphi. I use the one of F.Piette : http://www.rtfm.be/fpiette/indexuk.htm

Regards, Zif.
0
 

Author Comment

by:sakya
ID: 1362033
Thanks Zif.

Any other advice?

Sakya

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362034
sakya, sorry at the moment not, I'll look at the above code if I find some time, but I doubt if it will be helpfull, because I don't use them. Yuo really should have a look at these freeware components! No ActiveX, OLE, ... and very easy. Zif.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:sakya
ID: 1362035
Thanks, Zif.

I am now trying the components you said.
I want to give points to you, but I can't find a place to assess your answer.
What can I do?

Sakya.





0
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1362036
Hi sakya,

I'll answer the question, so you can grade it... BUT! Before grading it, please try it first with the components I proposed. If all things work out... then and only then grade my aswer.

sorry can't help you with this one. Had to much bugs in the components of delphi. I use the one of F.Piette : http://www.rtfm.be/fpiette/indexuk.htm

Regards, Zif.
0
 

Author Comment

by:sakya
ID: 1362037
Zif.

I exchanged the components included in Delphi for F.Piette's components that you said.

These are easy to use and working nicely.

Sakya
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now