zubie Posted November 20, 2003 Posted November 20, 2003 Hi all I am using SMTP to send an email I want to attach a text file to this but I dont know how to define it so that it gets attached correctly... Dim msgMail As New MailMessage() Dim stbMessageBody As New System.Text.StringBuilder() dim strFileLocation = Server.MapPath("") & "\Bonus-" & Format(Date.Now, "dd-MM-yyyy") & ".txt" Try 'CREATE MESSAGE BODY stbMessageBody.Append(strBody) msgMail.From = fromID msgMail.To = To_Email msgMail.Body = "Bonus Orders" msgMail.Subject = strSubject msgMail.Attachments.Add(TextFile????) <-- Problem SmtpMail.SmtpServer = strIPAddress SmtpMail.Send(msgMail) Catch ex As Exception Throw ex End Try hopefully someone can help .. thank ZuBiE Quote
zubie Posted November 21, 2003 Author Posted November 21, 2003 Figured it out .. or I found it on the net :) Add this to the code above Dim attAttachment As MailAttachment attAttachment = New MailAttachment(strFileLocation) msgMail.Attachments.Add(attAttachment) hope this helps someone else ZuBiE Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.