PC Review


Reply
Thread Tools Rate Thread

complete message

 
 
Vinnie
Guest
Posts: n/a
 
      8th Oct 2007
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

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      8th Oct 2007
On Oct 8, 7:59 pm, Vinnie <centro.ga...@gmail.com> wrote:
> 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"));

 
Reply With Quote
 
Vinnie
Guest
Posts: n/a
 
      8th Oct 2007
On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
>
> 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


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      8th Oct 2007
On Oct 8, 8:09 pm, Vinnie <centro.ga...@gmail.com> wrote:
> On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
>
>
>
> > 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

 
Reply With Quote
 
Vinnie
Guest
Posts: n/a
 
      8th Oct 2007
On Oct 8, 2:22 pm, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
> On Oct 8, 8:09 pm, Vinnie <centro.ga...@gmail.com> wrote:
>
>
>
> > On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.com> wrote:

>
> > > 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to save a complete thread in Newsgroups, instead of message by message. Gordon Windows Vista General Discussion 5 12th Jul 2009 04:10 PM
Re: How to save a complete thread in Newsgroups, NOT message by message. PA Bear [MS MVP] Windows Vista Mail 0 11th Jul 2009 05:10 PM
Form complete message =?Utf-8?B?TGltZQ==?= Microsoft Outlook Form Programming 1 29th Nov 2006 09:37 PM
Update Complete Message =?Utf-8?B?QW5keW0=?= Microsoft Excel Programming 3 7th Feb 2005 02:41 PM
Get complete message Leon Mayne [MVP] Microsoft Outlook VBA Programming 1 6th Feb 2004 08:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:06 PM.