?
Solved

TSMTP and TMIME

Posted on 1998-08-13
6
Medium Priority
?
326 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
Industry Leaders: 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

765 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