By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,056 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,056 IT Pros & Developers. It's quick & easy.

Add string as attachment

P: n/a
Hello,
this is my first post here..

I'm writing app where I need to send TextBox content as attachment.

typical attachment construction is like:

mail = new MailMessage()

mail.Attachment.Add(@"C:\fileToAdd.txt");
instead I need somethin like this:

string attachmentName = "att1.txt";
string attachmentContent = "1234945866";

How add string "attachmentConent" as attachment with "attachmentName"
as attachment name.
Google is no help :(

Sep 27 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You probably need to take your string and save it as a file.
Usually attachments are files. So using the StreamWriter class you can
save some text as a file and then attach that file.

Sep 27 '06 #2

P: n/a

Steven Nagy napisal(a):
You probably need to take your string and save it as a file.
Usually attachments are files. So using the StreamWriter class you can
save some text as a file and then attach that file.
I'm aware of such solution but file name is easy to guess and I'm
afraid some security risk - someone can inject data to file betwen
creaton and sending it - cousing bad things :(
Data from file are security keys and I dont want to write them anywere
on PC where applicacion will be working - only person who inserting
data should now it.
I now that I can write and delete file but there is moment where file
is on disk...
That's why I'm looking how to send string as attachments.

Sep 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.