Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indy Mail component assistance 2

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I'm trying to use the code and source I found here: to send an email from my program with an attachment.

I can run the source that I downloaded, but when I use that code I get error messages that none of the methods/properties are declared. Here's the code i'm trying to run:
Code:
[navy][i]// for automatic syntax highlighting see faq102-6487 
[/i][/navy]FrmMain.MailMessage.From.Address := frmMain.InfoArray[frmMain.JMSName];
  [navy][i]//frmMain.MailMessage.Recipients.EMailAddresses := ToEmail;
[/i][/navy]  frmMain.MailMessage.Recipients.EMailAddresses := [teal]'landrewsatmydomain'[/teal];
  TIdAttachment.Create(frmMain.MailMessage.MessageParts, [teal]'C:\co406\test.txt'[/teal]);

  [b]try[/b]
    [b]try[/b]
      frmMain.SMTP.Connect(1000);
      frmMain.SMTP.Send(frmMain.MailMessage);
    [b]except[/b] [b]on[/b] E:Exception [b]do[/b]
      ShowMessage([teal]'ERROR: '[/teal] + E.Message);
    [b]end[/b];
  [b]finally[/b]
    [b]if[/b] frmMain.SMTP.Connected [b]then[/b] frmMain.SMTP.Disconnect;
  [b]end[/b];

the error messages are:[tt]
Undeclared identifier: 'Connect'
Undeclared identifier: 'Send'
Undeclared identifier: 'Connected'
Undeclared identifier: 'Disconnect'[/tt]

but if I go to the help, I can find
TIdSMTP.Connect - Opens a connection to the SMTP server.

Any ideas on what I'm doing wrong?




Leslie

In an open world there's no need for windows and gates
 
You've definitely dropped a TidSMTP component on your form? Not something else you've accidentally labeled as SMTP?

I generally create and destroy TIdSMTP and TIdMessage in my code as needed. If you're sure you've got the correct component on your form, try creating TIdSMTP in your code block and try again.
 
Stupid questions, Leslie: presumably you've dropped the SMTP control on your form?

And is the above code from frmMain, or are you trying to manipulate things from another unit?
 
Ok, I double checked and I dropped on the IdSMTPServer component!!! Sometimes it IS the stupid questions!! Works no problem with the correct component.

Thanks!

Leslie
 
Funny you should say that, so have I!!

you know, i posted my original question at the end of the day Wednesday. Working on that was my last task of the day...to top it off the picture of the two components is exactly the same!!! So there I was, tired, worn out from looking into other issues all day, and Indy can't be considerate enough to make two different components at least look a LITTLE different!

I also need to revisit my comment above, it COMPILED just fine after making that change, but then I spent about 1/2 an hour trying to figure out a run time error before realizing I never added the new host name to the new component, I changed the component name, so it had nothing to connect to...Of course, that was the FIRST thing I worked on yesterday morning and was not quite awake yet....

Working fine now...moved back into my "learning java" programs (which I could carry on another entire gripe about!)

Happy Friday!

les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top