Solved

Retrieve E-mail address from XML (text) file

Posted on 2006-11-29
8
1,470 Views
Last Modified: 2007-12-19
Hi,

I need to retrieve the E-mail address (which is stored under <SMTP_Email_Address....) from the XML-file below.
Can anybody help me to write a function for this?


<?xml version="1.0" encoding="utf-16" ?>
<MessageAccount>
    <Account_Name type="SZ">MyName</Account_Name>
    <Connection_Type type="DWORD">00000003</Connection_Type>
    <Make_Available_Offline type="DWORD">00000001</Make_Available_Offline>
    <IMAP_Port type="DWORD">0000008f</IMAP_Port>
    <IMAP_Timeout type="DWORD">0000003c</IMAP_Timeout>
    <IMAP_Use_LSUB type="DWORD">00000001</IMAP_Use_LSUB>
    <IMAP_Polling type="DWORD">00000001</IMAP_Polling>
    <IMAP_Svr-side_Special_Folders type="DWORD">00000001</IMAP_Svr-side_Special_Folders>
    <IMAP_Sent_Items_Folder type="SZ">Verzonden items</IMAP_Sent_Items_Folder>
    <IMAP_Drafts_Folder type="SZ">Concepten</IMAP_Drafts_Folder>
    <IMAP_Prompt_for_Password type="DWORD">00000000</IMAP_Prompt_for_Password>
    <IMAP_Dirty type="DWORD">00000000</IMAP_Dirty>
    <IMAP_Poll_All_Folders type="DWORD">00000001</IMAP_Poll_All_Folders>
    <POP3_Server type="SZ">pop.mypop.nl</POP3_Server>
    <POP3_User_Name type="SZ">myemail@mypop.nl</POP3_User_Name>
    <POP3_Password2 type="BINARY">01000000d08c9dfger6784etc.</POP3_Password2>
    <POP3_Port type="DWORD">0000006e</POP3_Port>
    <POP3_Secure_Connection type="DWORD">00000000</POP3_Secure_Connection>
    <POP3_Timeout type="DWORD">0000003c</POP3_Timeout>
    <Leave_Mail_On_Server type="DWORD">00000001</Leave_Mail_On_Server>
    <Remove_When_Deleted type="DWORD">00000001</Remove_When_Deleted>
    <Remove_When_Expired type="DWORD">00000001</Remove_When_Expired>
    <Expire_Days type="DWORD">00000005</Expire_Days>
    <POP3_Skip_Account type="DWORD">00000000</POP3_Skip_Account>
    <POP3_Prompt_for_Password type="DWORD">00000000</POP3_Prompt_for_Password>
    <SMTP_Server type="SZ">smtp.mypop.nl</SMTP_Server>
    <SMTP_User_Name type="SZ">#smtp.mypop.nl</SMTP_User_Name>
    <SMTP_Use_Sicily type="DWORD">00000000</SMTP_Use_Sicily>
    <SMTP_Port type="DWORD">00000019</SMTP_Port>
    <SMTP_Secure_Connection type="DWORD">00000000</SMTP_Secure_Connection>
    <SMTP_Timeout type="DWORD">0000003c</SMTP_Timeout>
    <SMTP_Display_Name type="SZ">My Name</SMTP_Display_Name>
    <SMTP_Email_Address type="SZ">myname@mypop.nl</SMTP_Email_Address>
    <SMTP_Prompt_for_Password type="DWORD">00000000</SMTP_Prompt_for_Password>
</MessageAccount>

Thank you very much for your help.
Stef
0
Comment
Question by:Delphiwizard
  • 4
  • 4
8 Comments
 
LVL 28

Accepted Solution

by:
ciuly earned 500 total points
Comment Utility
well, yuo will be using some xml component. for example on using TXMLDocument (comes with delphi, see this:

procedure TForm1.FormCreate(Sender: TObject);
var xml:TXmlDocument; node:IXMLNode;
begin
  xml:=TXMLDocument.Create(self);
  xml.DOMVendor:=DomVendors.Vendors[1];// 0 is ms xml and it's stupid :D
  xml.LoadFromFile('c:\data.xml');
  xml.Active:=true;
  node:=xml.DocumentElement.ChildNodes.FindNode('SMTP_Email_Address');
  if node<>nil then showmessage(node.NodeValue)
               else showmessage('not found');
  xml.free;
end;

you will not be able to use teh default vendor in this case since it seems to have some issues swithing from default utf-8 encoding to utf-16. but since it's made by MS it is a "normal" thing :)
0
 
LVL 28

Expert Comment

by:ciuly
Comment Utility
oh, you put that XML in a file called c:\data.xml. OR you place it in a stream and pass the stream to loadfromstream. OR you place it in astring and assign the xml.xml.text:=the string..
0
 

Author Comment

by:Delphiwizard
Comment Utility
I put your code in the procedure for Button1.

But xml.LoadFromFile(ExtractFilePath(Application.ExeName)+'Test.xml');  gives an accessviolation.
Any ideas?
0
 
LVL 28

Expert Comment

by:ciuly
Comment Utility
post the entire code from button click
0
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

 

Author Comment

by:Delphiwizard
Comment Utility
I already got the solution.
xml.DOMVendor:=DomVendors.Vendors[1];
had to be set to
xml.DOMVendor:=DomVendors.Vendors[0];
0
 
LVL 28

Expert Comment

by:ciuly
Comment Utility
hm.. weird.
on my sistem xml.DOMVendor:=DomVendors.Vendors[0]; gives an error with the encoding. anyway, if it works, it's good so you can remove that line.
0
 

Author Comment

by:Delphiwizard
Comment Utility
Thank you for your help.
The XML-file is used in Windows Vista to store E-mail accounts (*.oeaccount). Maybe that's why the 0 in stead of 1?
Anyway it works perfectly.
0
 

Author Comment

by:Delphiwizard
Comment Utility
For other people who are interested in this code:
You should also add following units to the uses clause: XMLDOC, XMLIntf, XMLDom
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

12 Experts available now in Live!

Get 1:1 Help Now