Solved

Delphi send mail,

Posted on 2003-11-05
3
274 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 144
How to Get Images From Server to Client using App Tethering 1 41
Can Live bindings change TGrid Cell Colour ? 1 35
Firemonkey Queue list 1 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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