Imports ComponentPro.Net.Mail

Partial Public Class _Default
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

	End Sub

	''' <summary>
	''' Handles the Send button's Click event.
	''' </summary>
	''' <param name="sender">The button object.</param>
	''' <param name="e">The event arguments.</param>
	Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As EventArgs)
		Try
			' Create a new message object.
			Dim msg As New MailMessage()
			msg.From.Add(txtFrom.Text)
			msg.To.Add(txtTo.Text)
			msg.Subject = txtSubject.Text
			msg.BodyText = txtContent.Text

			Dim emlfile As String = AppDomain.CurrentDomain.BaseDirectory & "\Message.eml"
			msg.Save(emlfile)

			' Save as...
			Response.AppendHeader("content-disposition", "attachment; filename=""" & "Message.eml" & """")
			Response.ContentType = "application/octet-stream"
			Response.WriteFile(emlfile)
			Response.End()
		Catch exc As Exception
			lblResult.Text = String.Format(Nothing, "Exception: {0}", exc.Message)
		End Try
	End Sub
End Class