Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TSMTP and TMIME

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

636 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