Solved

TSMTP and TMIME

Posted on 1998-08-13
6
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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