[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

TSMTP and TMIME

Posted on 1998-08-13
6
Medium Priority
?
331 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
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 150 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

872 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