Add string as attachment

  • Thread starter Thread starter Marcin
  • Start date Start date
M

Marcin

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 :(
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top