Solved

Delphi send mail,

Posted on 2003-11-05
3
268 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
Comment Utility
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
Comment Utility
thanks, works perfect!
0
 
LVL 5

Expert Comment

by:snehanshu
Comment Utility
Great! Thanks,
...Shu
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now