m-jansen
asked on
Build file without storing to the hard drive then add it as attachment
How to make a file and place it as an attachment in an e-mail? My problem is how to build the CVS file. It would be great if it was possible to build it without saving anything to the hard drive.
This is how I send the e-mail.
public void SendMail()
{
try
{
MailMessage mail2 = new MailMessage();
mail2.To.Add("aahsdkjahsd@ yahoo.com" );
mail2.From = new MailAddress(TxtEpost.Text, TxtEtternavnForrnavn.Text, System.Text.Encoding.UTF8) ;
mail2.Subject = "Bestille katalog";
mail2.SubjectEncoding = System.Text.Encoding.UTF8;
Attachment atch = new Attachment("MyFile.CVS");
mail2.Attachments.Add(atch );
mail2.Body = "";
mail2.BodyEncoding = System.Text.Encoding.UTF8;
mail2.IsBodyHtml = false;
mail2.Priority = MailPriority.High;
//Add the Creddentials
SmtpClient client2 = new SmtpClient();
//For secure SMTP remove comments.....
//client2.Credentials = new System.Net.NetworkCredenti al("jaksla jsd@gmail. com", "password");
//client2.Port = 587;//or use 587, 465
client2.Host = "smtp.jaslkdj.com";
//client2.EnableSsl = true;
//client.SendCompleted += new SendCompletedEventHandler( client_Sen dCompleted );
client2.Send(mail);
}
catch (Exception ex)
{
//Label1.Text += ex.ToString();
}
This is how I send the e-mail.
public void SendMail()
{
try
{
MailMessage mail2 = new MailMessage();
mail2.To.Add("aahsdkjahsd@
mail2.From = new MailAddress(TxtEpost.Text,
mail2.Subject = "Bestille katalog";
mail2.SubjectEncoding = System.Text.Encoding.UTF8;
Attachment atch = new Attachment("MyFile.CVS");
mail2.Attachments.Add(atch
mail2.Body = "";
mail2.BodyEncoding = System.Text.Encoding.UTF8;
mail2.IsBodyHtml = false;
mail2.Priority = MailPriority.High;
//Add the Creddentials
SmtpClient client2 = new SmtpClient();
//For secure SMTP remove comments.....
//client2.Credentials = new System.Net.NetworkCredenti
//client2.Port = 587;//or use 587, 465
client2.Host = "smtp.jaslkdj.com";
//client2.EnableSsl = true;
//client.SendCompleted += new SendCompletedEventHandler(
client2.Send(mail);
}
catch (Exception ex)
{
//Label1.Text += ex.ToString();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER