Solved

Access violation using TIdMessage

Posted on 2008-06-21
7
987 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello Friends, My friends and relatives always ask me how to delete all the various types of emails at once in our g-mail  or windows live account.  So I researched this topic to find a unique solution to this query.  Here it is for those who do …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

690 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