Skip to content

Commit bee91e2

Browse files
authored
Update Mail4Delphi.Default.pas
1 parent fc3f882 commit bee91e2

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

scr/Mail4Delphi.Default.pas

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,22 @@ implementation
5151

5252
function TMail.AddFrom(const AMail: string; const AName: string = ''): IMail;
5353
begin
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;
6263
end;
6364

6465
function TMail.AddBCC(const AMail: string; const AName: string = ''): IMail;
6566
begin
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

99100
function TMail.SetHost(const AHost: string): IMail;
100101
begin
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;
105106
end;
106107

107108
function TMail.SetPassword(const APassword: string): IMail;
108109
begin
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;
113114
end;
114115

115116
function TMail.SetPort(const APort: Integer): IMail;
116117
begin
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;
121122
end;
@@ -136,7 +137,7 @@ function TMail.AddCC(const AMail: string; const AName: string = ''): IMail;
136137
begin
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

146147
function TMail.AddReplyTo(const AMail: string; const AName: string = ''): IMail;
147148
begin
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;
157158
function TMail.AddSubject(const ASubject: string): IMail;
158159
begin
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;
163164
end;
164165

165166
function TMail.AddTo(const AMail: string; const AName: string = ''): IMail;
166167
begin
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

262263
function TMail.SetUserName(const AUserName: string): IMail;
263264
begin
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;
268269
end;

0 commit comments

Comments
 (0)