Member_2_760301
asked on
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(i dmessage1. MessagePar ts,filenam e);
I need to work with the application while he is doing his upload. Is there a way to do it?
Thanks.
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(i
I need to work with the application while he is doing his upload. Is there a way to do it?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
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
ASKER
thanks ciuly
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: https://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.
you can read about them here: https://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.
ASKER
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?