C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Application windows, menus & toolbars »

Multiple Attachments in Mail + Windows Application


Posted Date: 13 Feb 2008    Resource Type: Code Snippets    Category: Application windows, menus & toolbars
Author: Deepika HaridasMember Level: Diamond    
Rating: 1 out of 5Points: 8



The Browse button click event Uses an OpenFileDialog control (i.e. here named as odlgAttachment) to allow the user to find an attachment to send, which is then added to an arraylist of MailAttachment objects.

ArrayList arlAttachments;


private void btnBrowse_Click(object sender, System.EventArgs e)
{
odlgAttachment.InitialDirectory = @"C:\";
odlgAttachment.Filter = "All Files (*.*)|*.*|HTML Files (*.htm;*.html)|*.htm|Microsoft Mail Documents (*.msg)|*.msg|Word Documents (*.doc)|*.doc|Excel Files(*.xl*)|*.xl*|Excel Worksheets (*.xls)|*.xls|Excel Charts (*.xlc)|*.xlc|PowerPoint Presentations (*.ppt)|*.ppt|Text Files (*.txt)|*.txt";
odlgAttachment.FilterIndex = 1;
// The OpenFileDialog control only has an Open button, not an OK button.
// However, there is no DialogResult.Open enum so use DialogResult.OK.
if (odlgAttachment.ShowDialog() == DialogResult.OK) {
if (arlAttachments == null) {
arlAttachments = new ArrayList();
// Clear the "(No Attachments)" default text in the ListView
lstAttachments.Items.Clear();
}
arlAttachments.Add(new MailAttachment(odlgAttachment.FileName));
// You only want to show the file name. The OpenFileDialog.FileName
// property contains the full path. So Split the path and reverse it
// to grab the first string in the array, which is just the FileName.
string[] strFileName= odlgAttachment.FileName.Split(Convert.ToChar(@"\"));
Array.Reverse(strFileName);
//all files are added to textbox
lstAttachments.Items.Add(strFileName[0]);
}
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
WinForms  .  Table  .  Resignation  .  Multiple attachments  .  Mail  .  Letter  .  Create  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Find if Sound Card / Device is install on system
Previous Resource: Load the form or activate it if already loaded
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use