Solved

Access violation using TIdMessage

Posted on 2008-06-21
7
984 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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 …
Pop culture is prime bait for hackers seeking to infect user’s computers and mobile devices with malicious malware. Hackers know exactly what the latest trends are online and know how to use them to their advantage.
The viewer will learn how to synchronize PHP projects with a remote server 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.

730 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