473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

complete message

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

Oct 8 '07 #1
4 1218
On Oct 8, 7:59 pm, Vinnie <centro.ga...@gmail.comwrote:
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
MailMessage msgMail = new MailMessage();
msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-
report.pdf"));

Oct 8 '07 #2
On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
>
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
Oct 8 '07 #3
On Oct 8, 8:09 pm, Vinnie <centro.ga...@gmail.comwrote:
On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
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
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...pplication.asp

Oct 8 '07 #4
On Oct 8, 2:22 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 8, 8:09 pm, Vinnie <centro.ga...@gmail.comwrote:
On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
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

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
thinghttp://www.codeproject.com/useritems/Email_Application.asp
Cool! thanks Master :)

Oct 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Max | last post by:
Hi guys, did some searching on the topic, but can't find much more then just basic info on binary trees. I need to write a binary tree implementation so that it is always complete. In other words...
1
by: Brad L. Meyer | last post by:
Hi all! Happy Holidays to all! I work for a nonprofit 501.3.c case management agency. All of the computers have MS ACCESS database software installed. Is it possible to recreate agency...
4
by: Kanaiya | last post by:
hello how to mak complete setup so any dependencies and dll which we have used are put in set file. -- With regards, Gangani Kanaiya.
3
by: Rahul Agarwal | last post by:
Hi In our web page we use a combination of HTML and server side controls and some of them have a custom attribute based on which we need to find and replace the values once the HTML is ready. ...
1
by: skootr | last post by:
Has anyone seen any COMPLETE bound form examples? By complete, I mean a form that has Add/Edit/Delete capabilities. Every example I've seen on the 'net, in books, and in the VB.Net Resource Kit...
4
by: Shelby | last post by:
Hi, if I launch another application in my vb code, how can I wait for it to complete first? Dim myProcess As Process myProcess = New Process myProcess.Start("test.exe") ' I want to wait for...
7
by: GeorgeAtkins | last post by:
I want to create a web-based form or page that consists of a series of formatted questions and answers. The form will resemble an existing paper form. When the form is filled in, I want the user to...
4
by: Hexman | last post by:
Code below ---- I've asked a similar question on this forum earlier. This is a slightly different situation. Previous Question ---- I'm trying to save some specific web pages to disk as...
1
by: piyushgpt1 | last post by:
My company has a web application running on JBoss-2.4.4_Tomcat-4.0.1. It works fine for a few days, but once or twice in a week, getting the exception :- Error : Runnable did not complete within...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.