Marcos
  • Marcos
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
I have in my hotmail folder "download" with sending mail rules content to this.

As I can with Delphi, download attach the email I'm sending to the folder "download".

Maybe using IMAP?



procedure TForm1.Button1Click(Sender: TObject);
Var
  oMail: IMail;
  oClient: TMailClient;
  oServer: TMailServer;
  oTools: TTools;
  infos: OleVariant;
  folders: OleVariant; oFolder: IImap4Folder;
  i, UBound, Count, iFol: Integer;
  oInfo: IMailInfo;
  mailFolder: WideString;
  fileName: WideString;
Begin
  Try
    oTools := TTools.Create(Application);

    // Create a folder named "inbox" under
    // current directory to store the email files
    mailFolder := GetCurrentDir() + '\inbox';
    oTools.CreateFolder(mailFolder);

    oServer := TMailServer.Create(Application);
    oServer.User := 'user@outlook.com';
    oServer.Password := 'password';
    oServer.Server :=  'imap-mail.outlook.com';
    oServer.Protocol := MailServerImap4;
    oServer.Port := 993;
    oServer.SSLType := ConnectSSL; 

    oClient := TMailClient.Create(Application);
    oClient.LicenseCode := 'TryIt';

    oClient.Connect1(oServer.DefaultInterface);
    self.Caption := 'Connected!';
    
    //GetFolders
    folders := oClient.Imap4Folders;
    iFol := VarArrayHighBound( folders, 1 );
    Memo1.Clear;
    For i := 0 To iFol Do Begin
       oFolder := IDispatch(VarArrayGet(infos, i)) As IImap4Folder ;
       Memo1.Lines.Add(oFolder.Name);
    End;

    infos := oClient.GetMailInfos();
    UBound := VarArrayHighBound( infos, 1 );
    Count := UBound+1;
    Memo1.Clear;
    For i := 0 To UBound Do Begin
      self.Caption := 'Va por: ' + IntToStr(i) + ' Total: ' + IntToStr(UBound);
      oInfo := IDispatch(VarArrayGet(infos, i)) As IMailInfo ;
      fileName := mailFolder + '\' + oTools.GenFileName(i) + '.eml';
      oMail := oClient.GetMail( oInfo );
      Memo1.Lines.Add(oMail.From.Address);
      if (oMail.From.Address = oServer.User) then begin
        oMail.SaveAs( fileName, true );
      end;
    End;
    oClient.Quit;

  Except
    On ep:Exception Do
      ShowMessage( 'Error: ' + ep.Message );
  End;
End;

UserPostedImage

Buuumm!! oClient.Connect1(oServer.DefaultInterface);

Unable to connect, I'm doing wrong?

Never came to oClient.Imap4Folders;
ivan
  • ivan
  • 100% (Exalted)
  • Administration
11 years ago

Hi, your codes are correct.

First of all, please make sure you defined const MailServerImap4 = 1;
Secondly, please check your connection to imap-mail.outlook.com like this:

under DOS command:
input:

telnet imap-mail.outlook.com 993

press enter.

If your connection to the server is ok, it should return a flash cursor, otherwise it returns "Could not open connection to ..."

If you don't have telnet client installed, please enable it like this:
http://social.technet.microsoft.com/wiki/contents/articles/910.enabling-telnet-client-in-windows-7.aspx 


By the way, could you generate a log file with LogFileName property and paste the content here ? please hide your password/user in the log file.
ivan
  • ivan
  • 100% (Exalted)
  • Administration
11 years ago
By the way, i just tested hotmail IMAP4 by imap4_full sample in EAGetMail, it works fine.
See the following screenshot.

so I doubt if your anti-virus/anti-spam/router/firewall blocked your outgoing 993 port on your machine.
 imap_full_vc.png You have insufficient rights to see the content.
Marcos
  • Marcos
  • 50.25% (Neutral)
  • Newbie Topic Starter
11 years ago
Thank you both.

The problem was oServer.SSLType := ConnectSSL;

The comment //oServer.SSLType := ConnectSSL;, and resolved my inconvenience.
ivan
  • ivan
  • 100% (Exalted)
  • Administration
11 years ago

Thank you both.

The problem was oServer.SSLType := ConnectSSL;

The comment //oServer.SSLType := ConnectSSL;, and resolved my inconvenience.

Originally Posted by: Marcos 




But in your codes, you didn't set

oServer.SSLConnection = True;

I thought you should set that .

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.