Click here to Skip to main content
15,903,201 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need Help Understanding Error Handling Pin
PIEBALDconsult6-Dec-10 12:21
mvePIEBALDconsult6-Dec-10 12:21 
Questionhow to convert dataset to excell ? Pin
Gali19786-Dec-10 9:04
Gali19786-Dec-10 9:04 
AnswerRe: how to convert dataset to excell ? Pin
Pawel Gielmuda6-Dec-10 22:50
Pawel Gielmuda6-Dec-10 22:50 
AnswerRe: how to convert dataset to excell ? Pin
RaviRanjanKr17-Dec-10 18:02
professionalRaviRanjanKr17-Dec-10 18:02 
QuestionSending attachments with SMTP Client Pin
musefan6-Dec-10 3:39
musefan6-Dec-10 3:39 
AnswerRe: Sending attachments with SMTP Client Pin
OriginalGriff6-Dec-10 3:42
mveOriginalGriff6-Dec-10 3:42 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 3:52
musefan6-Dec-10 3:52 
AnswerRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 4:15
musefan6-Dec-10 4:15 
After a bit more playing the answer to send using a file path is as follows...

using (System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(filename))
{
   message.Attachments.Add(attachment);
}
smtp.Send(message);


...I guess I was holding a handle on an System.Net.Mail.Attachment instance in my first code sample (somehow!). Though I would have liked to think this would not have keep a file open anyway!

this however does not work...

using(Stream stream = new MemoryStream(File.ReadAllBytes(filename)))
{
   message.Attachments.Add(stream, "myfile", null);
}
smtp.Send(message);


...because the Send() call is out of scope of the stream. Why this doesn't work but the above does I do not know.

EDIT: Actually I forgot to recompile - neither work (which I would suspect not to)
Life goes very fast. Tomorrow, today is already yesterday.

AnswerRe: Sending attachments with SMTP Client [modified] Pin
PIEBALDconsult6-Dec-10 4:16
mvePIEBALDconsult6-Dec-10 4:16 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 4:20
musefan6-Dec-10 4:20 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 4:24
mvePIEBALDconsult6-Dec-10 4:24 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 4:30
musefan6-Dec-10 4:30 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 4:40
mvePIEBALDconsult6-Dec-10 4:40 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 4:57
musefan6-Dec-10 4:57 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 5:32
mvePIEBALDconsult6-Dec-10 5:32 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 5:46
musefan6-Dec-10 5:46 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 5:57
mvePIEBALDconsult6-Dec-10 5:57 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 6:08
musefan6-Dec-10 6:08 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 6:22
mvePIEBALDconsult6-Dec-10 6:22 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 6:39
musefan6-Dec-10 6:39 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 7:21
mvePIEBALDconsult6-Dec-10 7:21 
AnswerRe: Sending attachments with SMTP Client Pin
Luc Pattyn6-Dec-10 4:16
sitebuilderLuc Pattyn6-Dec-10 4:16 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 4:26
mvePIEBALDconsult6-Dec-10 4:26 
GeneralRe: Sending attachments with SMTP Client Pin
musefan6-Dec-10 4:41
musefan6-Dec-10 4:41 
GeneralRe: Sending attachments with SMTP Client Pin
PIEBALDconsult6-Dec-10 4:58
mvePIEBALDconsult6-Dec-10 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.