Currently my email function is working and is able to send an attachment every time I click the button.
However every time I send an email, the data is just added to what is already in the file.
I was just wondering if it is possible to clear the test.html data inside then input the new data inside.
string attachmentBody = "Testing 1 2 3";
StreamWriter sw = new StreamWriter("Test.html", true, Encoding.UTF8);
sw.Write(attachmentBody);
sw.Close();
ttachment data = new Attachment("Test.html");
mailObj.Attachments.Add(data);
Problem is that you’re passing true to append param (take a look here for StreamWriter constructor syntax).
Try this: