Solved

Retrieve E-mail address from XML (text) file

Posted on 2006-11-29
8
1,531 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
[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
  • 4
8 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 18035902
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:2266180
ID: 18035905
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
ID: 18036026
I put your code in the procedure for Button1.

But xml.LoadFromFile(ExtractFilePath(Application.ExeName)+'Test.xml');  gives an accessviolation.
Any ideas?
0
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!

 
LVL 28

Expert Comment

by:2266180
ID: 18036035
post the entire code from button click
0
 

Author Comment

by:Delphiwizard
ID: 18036036
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:2266180
ID: 18036043
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
ID: 18036094
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
ID: 18036163
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

717 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