Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Marcos  
#1 Posted : Friday, November 8, 2013 5:26:47 AM(UTC)
Marcos

Rank: Newbie

Groups: Registered
Joined: 11/8/2013(UTC)
Posts: 2
Argentina
Location: Buenos Aires

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?


Code:

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;


Error

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

Unable to connect, I'm doing wrong?

Never came to oClient.Imap4Folders;
ivan  
#2 Posted : Friday, November 8, 2013 4:51:07 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,148

Thanks: 9 times
Was thanked: 54 time(s) in 54 post(s)

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.mi...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  
#3 Posted : Friday, November 8, 2013 4:56:09 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,148

Thanks: 9 times
Was thanked: 54 time(s) in 54 post(s)
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.
ivan attached the following image(s):
imap_full_vc.png
Marcos  
#4 Posted : Tuesday, November 12, 2013 3:13:38 AM(UTC)
Marcos

Rank: Newbie

Groups: Registered
Joined: 11/8/2013(UTC)
Posts: 2
Argentina
Location: Buenos Aires

Thank you both.

The problem was oServer.SSLType := ConnectSSL;

The comment //oServer.SSLType := ConnectSSL;, and resolved my inconvenience.
ivan  
#5 Posted : Tuesday, November 12, 2013 5:02:19 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,148

Thanks: 9 times
Was thanked: 54 time(s) in 54 post(s)
Originally Posted by: Marcos Go to Quoted Post
Thank you both.

The problem was oServer.SSLType := ConnectSSL;

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



But in your codes, you didn't set

oServer.SSLConnection = True;

I thought you should set that .
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.095 seconds.

EXPLORE TUTORIALS

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