@@ -51,21 +51,22 @@ implementation
5151
5252function TMail.AddFrom (const AMail: string; const AName: string = ' ' ): IMail;
5353begin
54- if ( AMail.Trim.IsEmpty) or (AName.Trim.IsEmpty) then
54+ if AMail.Trim.IsEmpty then
5555 begin
56- raise Exception.Create(' Informações do remetente incompletas para essa operação !' );
56+ raise Exception.Create(' E-mail do remetente não informado !' );
5757 Exit;
5858 end ;
5959 IdMessage.From.Address := AMail;
60- IdMessage.From.Name := AName;
60+ if not AName.Trim.IsEmpty then
61+ IdMessage.From.Name := AName;
6162 Result := Self;
6263end ;
6364
6465function TMail.AddBCC (const AMail: string; const AName: string = ' ' ): IMail;
6566begin
66- if ( AMail.Trim.IsEmpty) then
67+ if AMail.Trim.IsEmpty then
6768 begin
68- raise Exception.Create(' E-mail não informado para cópia oculta!' );
69+ raise Exception.Create(' E-mail não informado para cópia oculta!' );
6970 Exit;
7071 end ;
7172 IdMessage.BccList.Add.Text := AName + ' ' + AMail;
@@ -98,24 +99,24 @@ function TMail.SetBody(const ABody: string): IMail;
9899
99100function TMail.SetHost (const AHost: string): IMail;
100101begin
101- if ( AHost.Trim.IsEmpty) then
102- raise Exception.Create(' Servidor não informado!' );
102+ if AHost.Trim.IsEmpty then
103+ raise Exception.Create(' Servidor não informado!' );
103104 IdSMTP.Host := AHost;
104105 Result := Self;
105106end ;
106107
107108function TMail.SetPassword (const APassword: string): IMail;
108109begin
109- if ( APassword.Trim.IsEmpty) then
110- raise Exception.Create(' Senha não informado!' );
110+ if APassword.Trim.IsEmpty then
111+ raise Exception.Create(' Senha não informado!' );
111112 IdSMTP.Password := APassword;
112113 Result := Self;
113114end ;
114115
115116function TMail.SetPort (const APort: Integer): IMail;
116117begin
117118 if VarIsNull(APort) then
118- raise Exception.Create(' Senha não informado!' );
119+ raise Exception.Create(' Senha não informado!' );
119120 IdSMTP.Port := APort;
120121 Result := Self;
121122end ;
@@ -136,7 +137,7 @@ function TMail.AddCC(const AMail: string; const AName: string = ''): IMail;
136137begin
137138 if AMail.Trim.IsEmpty then
138139 begin
139- raise Exception.Create(' E-mail não informado para cópia!' );
140+ raise Exception.Create(' E-mail não informado para cópia!' );
140141 Exit;
141142 end ;
142143 IdMessage.CCList.Add.Text := AName + ' ' + AMail;
@@ -145,9 +146,9 @@ function TMail.AddCC(const AMail: string; const AName: string = ''): IMail;
145146
146147function TMail.AddReplyTo (const AMail: string; const AName: string = ' ' ): IMail;
147148begin
148- if ( AMail.Trim.IsEmpty) then
149+ if AMail.Trim.IsEmpty then
149150 begin
150- raise Exception.Create(' Informações de resposta incompletas para essa operação !' );
151+ raise Exception.Create(' E-mail para resposta não informado !' );
151152 Exit;
152153 end ;
153154 IdMessage.ReplyTo.Add.Text := AName + ' ' + AMail;
@@ -157,15 +158,15 @@ function TMail.AddReplyTo(const AMail: string; const AName: string = ''): IMail;
157158function TMail.AddSubject (const ASubject: string): IMail;
158159begin
159160 if ASubject.Trim.IsEmpty then
160- raise Exception.Create(' Assunto não informado!' );
161+ raise Exception.Create(' Assunto não informado!' );
161162 IdMessage.Subject := ASubject;
162163 Result := Self;
163164end ;
164165
165166function TMail.AddTo (const AMail: string; const AName: string = ' ' ): IMail;
166167begin
167- if ( AMail.Trim.IsEmpty) or (AName.Trim.IsEmpty) then
168- raise Exception.Create(' Informações do destinatário incompletas para essa operação !' )
168+ if AMail.Trim.IsEmpty then
169+ raise Exception.Create(' E-mail do destinatário não informado !' )
169170 else
170171 IdMessage.Recipients.Add.Text := AName + ' ' + AMail;
171172 Result := Self;
@@ -233,7 +234,7 @@ function TMail.SendMail: Boolean;
233234 except
234235 on E: Exception do
235236 begin
236- raise Exception.Create(' Erro na conexão ou autenticação: ' + E.Message);
237+ raise Exception.Create(' Erro na conexão ou autenticação: ' + E.Message);
237238 Exit(False);
238239 end ;
239240 end ;
@@ -261,8 +262,8 @@ function TMail.SetUpEmail: Boolean;
261262
262263function TMail.SetUserName (const AUserName: string): IMail;
263264begin
264- if ( AUserName.Trim.IsEmpty) then
265- raise Exception.Create(' Usuário não informado!' );
265+ if AUserName.Trim.IsEmpty then
266+ raise Exception.Create(' Usuário não informado!' );
266267 IdSMTP.Username := AUserName;
267268 Result := Self;
268269end ;
0 commit comments