Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 188217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:58:03+00:00 2026-05-11T15:58:03+00:00

I have a mail application. While sending to each recipient I am writing to

  • 0

I have a mail application. While sending to each recipient I am writing to an XML file named mail.xml. I use the following code:

Dim from As String = txtFrom.Text Dim txto As String = txtTo.Text Dim subj As String = txtSubject.Text Dim body As String = txtBody.Text Dim settings As New XmlWriterSettings() settings.Indent = True settings.NewLineOnAttributes = True Using writer As XmlWriter = XmlWriter.Create('C:\xmlmailfile.xml', settings)   writer.WriteStartDocument()   writer.WriteStartElement('EMail')   writer.WriteStartElement('From')   writer.WriteStartAttribute('From')   writer.WriteValue(from)   writer.WriteEndAttribute()   writer.WriteStartElement('To')   writer.WriteStartAttribute('To')   writer.WriteValue(txto)   writer.WriteEndAttribute()   writer.WriteStartElement('Subject')   writer.WriteStartAttribute('Subject')   writer.WriteValue(subj)   writer.WriteEndAttribute()   writer.WriteStartElement('Body')   writer.WriteStartAttribute('Body')   writer.WriteValue(body)   writer.WriteEndAttribute()   writer.WriteEndElement()   writer.WriteEndDocument()   writer.Flush() End Using 

And the output is:

<?xml version='1.0' encoding='utf-8' ?>  <EMail>   <From From='abc@xyz.com'>   <To To='def@pqr.com'>     <Subject Subject='Hi'>       <Body Body='Hello' />      </Subject>   </To>   </From>  </EMail> 

Here I am not able to append to existing output. Only one ‘Email’ section is being output. I want to add an ‘Email’ section for each recipient. However, in the above code new sections replace previously written ones.

How can I accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:58:03+00:00Added an answer on May 11, 2026 at 3:58 pm

    An XML document can only have a single root element. I suggest you have a root Emails element with Email elements under it. Note that you still won’t be able to append new elements within the same file – you’d have to read the existing file and rewrite it. In theory you could just overwrite the last line (you always know how long it will be, so you could just seek to the right place) but it’s more robust to read the file into memory, append a new Email element, and then write out the whole document again.

    I also think it’s a bit strange to have the Body element within the subject element. I’d suggest a structure like this:

    <?xml version='1.0' encoding='utf-8' ?>  <Emails>   <Email>     <From Address='abc@xyz.com'>     <Recipient Type='To' Address='def@pqr.com' />     <Recipient Type='Cc' Address='ghi@pqr.com' />     <Subject>Hi</Subject>     <Body>Body text</Body>    </Email>   <Email>     <!-- Second email comes here -->   </Email> </Emails> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code in my VB.NET application to send an HTML e-mail
Is there some way to have the Mail Merge capability in my application? Maybe
Let's say that I have written a custom e-mail management application for the company
I have an HTML Mail template, with a place holder for the image. I
I have a JLabel which has an e-mail address in it. I used HTML
I have noticed that some apps like Safari and Mail show a loading indicator
I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my
I have a little python script that pulls emails from a POP mail address
I have a Microsoft keyboard with a series of non-standard buttons such as Mail,
I have one interesting problem. I must parse mail body (regular expression), get some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.