Solved

Access violation using TIdMessage

Posted on 2008-06-21
7
970 Views
Last Modified: 2013-12-14
Hi,
I had a simple email smtp using Indy 8 which worked ok, when I moved up to Indy 9 the program keeps throwing Eaccess violations. I am using Borland C++ 6 pro. The strange thing is if I set the IdMessage and IdSmtp variables at design time it works fine with no exceptions.

IdMessage1->From->Address = Fromtxt->Text;

           IdMessage1->Recipients->EMailAddresses = Totxt->Text;

           IdMessage1->Subject = Subjecttxt->Text;

           IdMessage1->Body->CommaText = Bodytxt->Text;

 

           IdSMTP1->Host = Hosttxt->Text;

           IdSMTP1->Password = Passwordtxt->Text;

           IdSMTP1->UserId = Useridtxt->Text;

 

 

           IdSMTP1->Connect();

           IdSMTP1->Send(IdMessage1);

           IdSMTP1->Disconnect();

Open in new window

0
Comment
Question by:sampro
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 21838606
>> The strange thing is if I set the IdMessage and IdSmtp variables at design time it works fine with no exceptions

I assume that you mean debug mode inside the IDE...
Is that true?

In this case you face a difficult problem...:-(
First of all you have to see where the access violation occures...
This can be done by adding a ShowMessage() line and see where the problem located..

George Tokas.
0
 

Author Comment

by:sampro
ID: 21838910
I assume that you mean debug mode inside the IDE...
Is that true?

If I set IdMessage properties using the Object inspector it works fine. If I try to set them at run  time with the code the exceptions start.
 It seems I can set the Subject and Body text at runtime but the From->Address and Recipients->EMailAdresses throwing EAccessviolation.
0
 

Author Comment

by:sampro
ID: 21838950
I assume that you mean debug mode inside the IDE...
Is that true?

If I set IdMessage properties using the Object inspector it works fine. If I try to set them at run  time with the code the exceptions start.
 It seems I can set the Subject and Body text at runtime but the From->Address and Recipients->EMailAdresses throwing EAccessviolation.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 16

Expert Comment

by:George Tokas
ID: 21841579
Hold that a sec...
By using Object Inspector and set the values work fine. FACT!
By using the content of a TEditBox or a TLabel fails??
meaning:
IdMessage1->From->Address = Fromtxt->Text;//Fromtxt is an editbox I assume....
the next line throws access violation??
THIS LOOKS STRANGE even for me I'm not using Indy (even though registered to comercial projects with the company)...
So what I propose:
Place a break point at the first line of code.
VERIFY that AFTER each line executed (Use F8) that all values are set as they should..
And find the line raising the access violation and report...

George Tokas.
0
 

Author Comment

by:sampro
ID: 21841738
Thanks for getting back George.

I had done pretty much what you have said, and I could see some values set but the others weren't  accessible!
 This problem was driving me nuts, after reinstalling  9 a few times  I did a complete reinstall of Builder added the updates  took out Indy 8 files which came with it and reinstalled version 9. The problem has gone. All I can think of is there must have been a conflict some where between version 8 and 9 perhaps.
0
 
LVL 16

Expert Comment

by:George Tokas
ID: 21841962
If the problem is fixed then all are good...:-)
Usually those kind of problems appears when upgrading...
Usually are previous libraries accessed and that leads to access violations...
That is and why in my current article series about Direct3D9 at http://bcbjournal.org didn't create components as version 1 yet even though some other people would do that...
Prefer a set of classes for the time...

George Tokas.
0
 

Accepted Solution

by:
sampro earned 0 total points
ID: 21989113
The problem was fixed to a point. I Created a new project and using Indy message component  there is no problems setting the IdMessage1->From->Address at run time. So the problem lay in the current project somewhere.
 The only way I could resolve it was copying the current programs interface  to a new project and adding  the code (long task) bit by bit and testing the message component.  As far as I can see all the code is back and everything works fine, so still not sure what was causing the exception.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The most common mistakes I hear or read about email usually begin with people talking about POP3 and IMAP, so let's clear those off the table: POP3 and IMAP have absolutely nothing to do with sending or receiving email, so get that notion out of you…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

758 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

19 Experts available now in Live!

Get 1:1 Help Now