indy smtp with attachment

Hello.
I have made a tool that emails with indy an archive. The all process works fine, but during the upload of attachment my application is blocked. I can't control it. For attaching the file I create the Tidattachmentfile and I create it like:
Tidattachmentfile.Create(idmessage1.MessageParts,filename);
I need to work with the application while he is doing his upload. Is there a way to do it?

Thanks.
LVL 11
A. Cristian CsikiSenior System AdministratorAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
yes. just put a TIdAntiFreeze on the same form/datamodule with the other indy components.
0
 
A. Cristian CsikiSenior System AdministratorAuthor Commented:
Hi ciuly.
TIdAntiFreeze component didn't free my application. After the upload begin for attachment I can't use my application any more until finish the email rutine.

Any ideas?
0
 
2266180Commented:
you're not using something right :)

may I see the setup of your components? delete the unnecessary code, leave the procedures and events there, but empty (well, place some comment in them so it won't be removed by the compiler) and then post the code here so I can see how you set it up.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
A. Cristian CsikiSenior System AdministratorAuthor Commented:
Sure.



The unit:
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack,
  IdSSL, IdSSLOpenSSL, IdMessage, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
  IdMessageClient, IdSMTPBase, IdSMTP, ExtCtrls;
 
type
  TForm1 = class(TForm)
    IdSMTP1: TIdSMTP;
    IdMessage1: TIdMessage;
    IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
....
 
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
  uses idattachmentfile;
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
if fileexists('c:\filename.rar') then
begin
s:='C:\filename '+ FormatDateTime('yy.mm.dd_hh-nn-ss', Now)+'.rar';
label1.Caption:=s;
RenameFile('c:\filename.rar', 'C:\filename '+ FormatDateTime('yy.mm.dd_hh-nn-ss', Now) + '.rar');
Tidattachmentfile.Create(idmessage1.MessageParts,s);
idmessage1.Body.Text:='filename '+datetimetostr(now);
idsmtp1.Connect;                                                             
idsmtp1.Send(idmessage1);
idsmtp1.Connected;
 end;
 
the dfm:
object Form1: TForm1
  Left = 30000
  Top = 114
  Width = 181
  Height = 143
  Caption = 'eMail'
  Color = clWhite
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 0
    Top = 56
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
 object IdAntiFreeze1: TIdAntiFreeze
    Left = 96
    Top = 80
  end
  object Button1: TButton
    Left = 0
    Top = 32
    Width = 75
    Height = 25
    Caption = 'send'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 80
    Top = 32
    Width = 41
    Height = 25
    Caption = 'init'
    TabOrder = 1
    OnClick = Button2Click
  end
  object Memo1: TMemo
    Left = 0
    Top = 0
    Width = 169
    Height = 105
    TabOrder = 2
  end
  object Button3: TButton
    Left = 0
    Top = 24
    Width = 75
    Height = 25
    Caption = 'close'
    TabOrder = 3
    OnClick = Button3Click
  end
  object IdSMTP1: TIdSMTP
    IOHandler = IdSSLIOHandlerSocketOpenSSL1
    HeloName = 'csd'
    Host = 'smtp.gmail.com'
    Password = 'contabilitate'
    Port = 587
    SASLMechanisms = <>
    UseTLS = utUseRequireTLS
    Username = '..'
    Left = 32
  end
  object IdMessage1: TIdMessage
    AttachmentEncoding = 'UUE'
    Body.Strings = (
      '..')
    BccList = <
      item
        Address = '..'
        Text = '..'
        Domain = 'gmail.com'
        User = '..'
      end>
    CCList = <>
    Encoding = meDefault
    FromList = <
      item
        Address = '..@gmail.com'
        Text = '..@gmail.com'
        Domain = 'gmail.com'
        User = '..'
      end>
    From.Address = '..'
    From.Text = '..'
    From.Domain = 'gmail.com'
    From.User = '..'
    Recipients = <>
    ReplyTo = <>
    Subject = '..'
    Sender.Address = '..@gmail.com'
    Sender.Text = '..@gmail.com'
    Sender.Domain = 'gmail.com'
    Sender.User = '..'
    ConvertPreamble = True
  end
  object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL
    Destination = 'smtp.gmail.com:587'
    Host = 'smtp.gmail.com'
    MaxLineAction = maException
    Port = 587
    DefaultPort = 0
    SSLOptions.Method = sslvSSLv2
    SSLOptions.Mode = sslmUnassigned
    SSLOptions.VerifyMode = []
    SSLOptions.VerifyDepth = 0
    Left = 56
  end
  
end

Open in new window

0
 
A. Cristian CsikiSenior System AdministratorAuthor Commented:
thanks ciuly
0
 
2266180Commented:
damn. I didn't get a notification for your comment. sorry. EE had some issues with their mail servers these past weeks. I (and almost all other experts) missed on a lot, mostly new questions, but some comments as well. after a while they started sending duplicate email notifications for same comments.
you can read about them here: http://www.experts-exchange.com/Community_Support/EE_Bugs/#browseZones
just so you know me not replying was not my fault. I never ignore comments.

as a tip for the future, when you don't get any response in a few days, it is a good idea to ping the expert(s). just post a comment like "any news?". we don't mind. on the contrary.
these few weeks were indeed with general site-wide mail issues, but sometimes it happens once in a while that some emails to not get sent. (the target email server is down for example, so the email is wasted). pinging is a good thing when you don't get any response as it cna be a "system malfunction" which causes it ;)

again, sorry for the inconvenience.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.