Solved

Access violation using TIdMessage

Posted on 2008-06-21
7
979 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

825 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