send email attachment

Posted on 2006-04-19
Last Modified: 2012-05-05

i have an XmlDocument i want to email.   It does not have a file path - it is stored as a property of my class.

How do i do this?  without saving to file first.

i.e i want to say

MailAttachment attachment = new MailAttachment(this.myxmlDocument);  
Question by:MrKevorkian
    LVL 14

    Expert Comment

    That is not possible as far I as know. You will need to write the XmlDocument to your hdd and attach it that way.
    LVL 1

    Author Comment

    just found out  you can do it in 2005 with

    LVL 14

    Expert Comment

    Could you post the url/code for it (to help some fellow coders)? ;)
    LVL 1

    Accepted Solution

    Since an Attachment in the SMTP Protocol requires that a file will be chosen from the Hard Disk
    and not Memory, You will have to code internal routines that handle this.
    Still the routines will be preparing a file that will be temporarly saved and deleted to the HardDisk,
    But this way it will be transperent to you.

    MailAttachment class should be created with 2 or more constructors. 1 for file name, 1 for file stream.
    Second one should handle the file writing and attachment behind the scenes.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 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

    15 Experts available now in Live!

    Get 1:1 Help Now