Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Delphi send mail,

Posted on 2003-11-05
3
273 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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