Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

complete message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vinnie - 08 Oct 2007 18:59 GMT
To create a Mail Message, i can use the MailMessage(from, to) and so
send the mail. But how should i change the code in case  there is also
a file to attach in the form? (let's say that i have already placed
the upload-file control on the page).

Thanks
~V
Alexey Smirnov - 08 Oct 2007 19:02 GMT
> To create a Mail Message, i can use the MailMessage(from, to) and so
> send the mail. But how should i change the code in case  there is also
[quoted text clipped - 3 lines]
> Thanks
> ~V

MailMessage msgMail = new MailMessage();
msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-
report.pdf"));
Vinnie - 08 Oct 2007 19:09 GMT
> MailMessage msgMail = new MailMessage();
> msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-
> report.pdf"));

hi Alexey thanks,
but how do i relate this attachment to the mail that the user is now
sending me?
I mean, if on a webpage there is a form to send an email message to
the webmaster, and is available the option to upload a file and attach
it to this mail, how can this  should be coded? (because if the user
upload a file, i don't know the name of that file)

Thanks
Alexey Smirnov - 08 Oct 2007 19:22 GMT
> > MailMessage msgMail = new MailMessage();
> > msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-
[quoted text clipped - 9 lines]
>
> Thanks

it's pretty easy, you save the file and attach to a message

For example (c#):

// get the name of the file, Upload is a control name
string fileName = Path.GetFileName(Upload.PostedFile.FileName);
Upload.PostedFile.SaveAs(@"C:\Website\" + fileName);

// then attach it
MailMessage msgMail = new MailMessage();
msgMail.Attachments.Add(new MailAttachment(@"C:\Website\" +
fileName));
....

Look at the following article, I think it does more or less the same
thing
http://www.codeproject.com/useritems/Email_Application.asp
Vinnie - 08 Oct 2007 19:26 GMT
> > > MailMessage msgMail = new MailMessage();
> > > msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-
[quoted text clipped - 26 lines]
> Look at the following article, I think it does more or less the same
> thinghttp://www.codeproject.com/useritems/Email_Application.asp

Cool! thanks Master :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.