So, I've got an I.T Request program, that works by passing a few strings to the database. However, this only works within the same network (or at least with access to the network).
So I'm writing in a method that generates an email and sends that, with a batch file as an attachment that will then run the db insert method. I know how to create said batch file, and attach it, however the problem is that all the methods that I've seen physically create the file in a defined location, then attach it.
How can I create a temporary file, that will not be saved on the user's PC, and sent off as part of the auto-generated email?
void SendEmail(Request_View view)
{
MailMessage mail = new MailMessage("from@email.com", "to@email.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "gmail.com";
mail.Subject = "Subject";
mail.Body = ""Message";
// Create temp batch file
mail.Attachments.Add(new Attachment(BatchFile.bat));
client.Send(mail);
}