Setting from email address in code
-
- Posts: 4
- Joined: Tue Jan 17, 2006 3:05 pm
Setting from email address in code
Is it possible to set the from email address in code ?
One of our clients has set up their outgoing email not to send if the from address is not recoginsed so I want to use a specific address and not allow the user to enter one.
One of our clients has set up their outgoing email not to send if the from address is not recoginsed so I want to use a specific address and not allow the user to enter one.
uses madExcept;
MailFrom := 'test@test.com'; // madExcept 2.x
MESettings.MailFrom := 'test@test.com'; // madExcept 3.x
MailFrom := 'test@test.com'; // madExcept 2.x
MESettings.MailFrom := 'test@test.com'; // madExcept 3.x
-
- Posts: 4
- Joined: Tue Jan 17, 2006 3:05 pm
I can't get this to work ! I am using version 3.0a.
If I allow the user to enter a from email address in the EmailEdit field on then ContactForm then everything is ok.
If I remove the EmailEdit field and use the code above then the email is not sent. I think (but not sure) that this is because the from address is blank.
I have madExcept set to 'act as a SMTP main client'.
The exception I am generating is not very complicated:
procedure TForm1.Button1Click(Sender: TObject);
begin
MESettings.MailFrom := 'fred@abc.co.uk';
raise Exception.Create ('Hello');
end;
If I allow the user to enter a from email address in the EmailEdit field on then ContactForm then everything is ok.
If I remove the EmailEdit field and use the code above then the email is not sent. I think (but not sure) that this is because the from address is blank.
I have madExcept set to 'act as a SMTP main client'.
The exception I am generating is not very complicated:
procedure TForm1.Button1Click(Sender: TObject);
begin
MESettings.MailFrom := 'fred@abc.co.uk';
raise Exception.Create ('Hello');
end;
-
- Posts: 4
- Joined: Tue Jan 17, 2006 3:05 pm
-
- Posts: 4
- Joined: Tue Jan 17, 2006 3:05 pm