save e-mail to file?

BRYPIE04

New member
Joined
Sep 2, 2005
Messages
2
Programming Experience
5-10
Hi there,

I have the following code:

Private Function SendEmail(ByVal EMailMsg As Mail.MailMessage)
'Local variables.
Dim strMailServer As String
EMailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
EMailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", <<USER>>)
EMailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", <<PASSWORD>>)
'EMailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", <<SERVER>>)
'Send the e-mail.
Try
Mail.SmtpMail.SmtpServer = <<SERVER>>
Mail.SmtpMail.Send(EMailMsg)

Catch ex As System.Web.HttpException
'Save the e-mail for sending later.
End Try

End Function


Basically, I want to send the e-mail (this code works fine), but if the e-mail can't be sent for any reason, I want to save it to the hard disk, to be sent at a later date.

How do I do this?

Cheers,
Bryan.
 
Try putting something like this between Catch and End Try:
VB.NET:
[color=Blue]Dim [/color]myWriter [color=Blue]As New[/color] IO.StreamWriter("c:\email.txt")
myWriter.WriteLine(EMailMsg)
myWriter.Close()

Hope this helps.
 
Ok - I'll give that a shot, and let you know how I get on...
 
Back
Top