Solved

Delphi send mail,

Posted on 2003-11-05
3
272 Views
Last Modified: 2010-04-03
Hi, i have the following code that uses a memo to store  e-mail addresses,
the memo loads the address from a file and mails to all the addresses, I need to know if you can load it directly from a file using t-stringlist instead of loading it into the memo, if i dont use the memo will it sent to all the addresses in the file?
//
Memo1.lines.LoadFromFile'c:\address.txt';
NMSMTP1.Host :=  smtp server;
       NMSMTP1.Connect;
       NMSMTP1.PostMessage.ToAddress.AddStrings (memo1.Lines);
       NMSMTP1.PostMessage.FromAddress := 'bla@mail.com';
       NMSMTP1.PostMessage.Subject := 'subject';
       NMSMTP1.PostMessage.Body.Text :='body';
       NMSMTP1.PostMessage.Attachments.Text := 'c:\file.txt';
       NMSMTP1.SendMail;
       NMSMTP1.Disconnect;
//
i hope you understand..
0
Comment
Question by:herd_bone
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
snehanshu earned 60 total points
ID: 9685223
I am not sure if I understood your question.
Doesn't this work: ??

procedure TForm1.Button4Click(Sender: TObject);
Var
  MyLst: TStringList;
begin
     MyLst := TStringList.Create;
       MyLst.LoadFromFile('C:\address.txt');
       NMSMTP1.Host :=  smtp server;
       NMSMTP1.Connect;
       NMSMTP1.PostMessage.ToAddress.AddStrings(MyLst);
//       NMSMTP1.PostMessage.ToAddress.AddStrings (memo1.Lines);
       NMSMTP1.PostMessage.FromAddress := 'bla@mail.com';
       NMSMTP1.PostMessage.Subject := 'subject';
       NMSMTP1.PostMessage.Body.Text :='body';
       NMSMTP1.PostMessage.Attachments.Text := 'c:\file.txt';
       NMSMTP1.SendMail;
       NMSMTP1.Disconnect;

     MyLst.Free;

end;
0
 

Author Comment

by:herd_bone
ID: 9686627
thanks, works perfect!
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9686752
Great! Thanks,
...Shu
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question