Recent

Author Topic: Send message with Indy  (Read 10225 times)

trezub

  • Newbie
  • Posts: 1
Send message with Indy
« on: April 19, 2006, 10:13:24 pm »
Indy10.

I send message with Indy but message reseived as message-news-groups, and not simple message.

1) How I can send a simple message?

and question two:
2) Who create attachment's?

carlos_oliveira_10

  • New member
  • *
  • Posts: 6
RE: Send message with Indy
« Reply #1 on: September 06, 2008, 03:44:28 am »
I need send emails with attchment's...can someone help me?

I send emails without attchment's without problems...

Thanks

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
RE: Send message with Indy
« Reply #2 on: September 06, 2008, 11:15:22 am »
I don't want to be "stealing customers" here, I'm sure Indy 10 can send emails with attachments, but if you continue having trouble, you can try http://wiki.freepascal.org/lNet. We have a ready to use SMTP example in which you can send attachments. The SMTP example is in "examples/visual/smtp" subdir.

carlos_oliveira_10

  • New member
  • *
  • Posts: 6
RE: Send message with Indy
« Reply #3 on: September 12, 2008, 03:45:09 am »
Thank you for help.
The problem is that I have to upgrade a software that already exists (and using INDY) and therefore the solution dont solve my problem.

if anyone knows how to do ... please help me :)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1891
RE: Send message with Indy
« Reply #4 on: September 12, 2008, 10:06:25 am »
Why don't you have a look at the Indy website?

http://www.indyproject.org/sockets/blogs/rlebeau/2005_08_17_a.de.aspx

jbreits

  • New Member
  • *
  • Posts: 15
    • http://www.breittechnologies.com
Send message with Indy
« Reply #5 on: September 25, 2008, 07:30:06 pm »
This example code is from Delphi, but I expect it to be the same or very close in Lazarus.

Make sure you have a TIdSMTP and TIdMessage component on your form.

Code: [Select]
smtpServer             : TIdSMTP;
msgEMail               : TIdMessage;


To setup a simple message do something like this:


Code: [Select]
msgEMail.Clear;

msgEMail.From.Name                 := 'Your Name Here';
msgEMail.From.Address              := 'YourAddress@whatever.com';
msgEMail.Recipients.EMailAddresses := 'SendToThisAddy@whatever.com';
msgEMail.Subject                   := 'Your subject';

msgEMail.Body.Add    ('Line 1.');
msgEMail.Body.Add    ('Line 2.');
msgEMail.Body.Add    ('Line 3.');



If you want to add an attachment to the message, first add IdAttachmentFile to the Uses section.  Then create the attacment with a line like this:

Code: [Select]
TIdAttachmentFile.Create(msgEMail.MessageParts, 'c:\FileToAttach.txt');


To send the message, do something like this:

Code: [Select]
With smtpServer Do Begin
  Host := 'YourSMTPServer';
  Try
    Connect;
    Send    (msgEMail);
    Disconnect;
  Except
    If Connected Then
      Try
        Disconnect;
      Except
      End;
    ShowMessage ('Error while sending E-Mail!');
  End;
End;
--
JBreits

targinosilveira

  • Newbie
  • Posts: 3
    • http://targinosilveira.web44.net
Send message with Indy
« Reply #6 on: October 02, 2008, 07:13:46 pm »
ok, this code may be used from Delphi but if you need use a smtp like google or yahoo that use SSL, you need 3 dll's.

It's wuold work into Lazarus and Linux ?

 

TinyPortal © 2005-2018