Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email with attachments using aspx

Status
Not open for further replies.
Jun 7, 2005
10
US
I have a form that works sending e-mails in aspx. I need to also give the user the ability to send attachments. The user wants the email to get delivered with or without attachments. Got any ideas? Here is the code I need to modify:

<%@ import Namespace="System.Web.Mail" %>
<script runat="server">

Sub buttonSend_Click(sender As Object, e As EventArgs)
Dim emailMessage As MailMessage
emailMessage = New MailMessage
emailMessage.From = textEmail.Text
emailMessage.To = textTo.Text
emailMessage.Subject = textSubject.Text
emailMessage.Body = "Department: " & textDept.Text & vbcrlf & vbcrlf & "Name: " & textName.Text & vbcrlf & vbcrlf & "Url: " & textUrl.Text & vbcrlf & vbcrlf & "Message: " & textMessage.Text

SmtpMail.SmtpServer="server name goes here"
Try
SmtpMail.Send(emailMessage)
labelStatus.Text = "Thank You!"
buttonSend.Enabled = False
Catch ex As Exception
labelStatus.Text = "Unable to send e-mail message."
End Try

End Sub

Sub buttonNewMessage_Click(sender As Object, e As EventArgs)
textEmail.Text = ""
textSubject.Text = ""
textDept.Text = ""
textName.Text = ""
textUrl.Text = ""
textMessage.Text = ""
buttonSend.Enabled = True
labelStatus.Text = ""
End Sub

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top