Link to home
Start Free TrialLog in
Avatar of Stef Merlijn
Stef MerlijnFlag for Netherlands

asked on

Retrieve E-mail address from XML (text) file

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
ASKER CERTIFIED SOLUTION
Avatar of 2266180
2266180
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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..
Avatar of Stef Merlijn

ASKER

I put your code in the procedure for Button1.

But xml.LoadFromFile(ExtractFilePath(Application.ExeName)+'Test.xml');  gives an accessviolation.
Any ideas?
post the entire code from button click
I already got the solution.
xml.DOMVendor:=DomVendors.Vendors[1];
had to be set to
xml.DOMVendor:=DomVendors.Vendors[0];
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.
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.
For other people who are interested in this code:
You should also add following units to the uses clause: XMLDOC, XMLIntf, XMLDom