Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access violation using TIdMessage

Posted on 2008-06-21
7
Medium Priority
?
1,001 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: 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

What is Usenet? There are many different opinions on exactly what Usenet is an isn't. Many opinions are incorrect simply out of ignorance. The Wikipedia listing about Usenet does a good job of explaining it, so instead of repeating it all here I wi…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…
Suggested Courses
Course of the Month20 days, 20 hours left to enroll

810 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