hello there i want to send an email in which user has selected an attachment to send. below is the code for it:
Imports System.Web.Mail
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents txtToEmail As System.Web.UI.WebControls.TextBox
Protected WithEvents lbFiles As System.Web.UI.WebControls.ListBox
Protected WithEvents butOK As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub butOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butOK.Click
Dim TheMailMessage As New MailMessage
Dim TheMailConnection As SmtpMail
Dim TheAttachment As MailAttachment
Dim TheItem As ListItem
TheMailMessage.From = "shahdhruv47@yahoo.com"
TheMailMessage.To = txtToEmail.Text
TheMailMessage.Subject = "File Request"
TheMailMessage.Body = "Attached is the information " _
& "you requested."
For Each TheItem In lbFiles.Items
If TheItem.Selected = True Then
TheAttachment = New MailAttachment( _
Server.MapPath("/Email/C9/" & TheItem.Value))
TheMailMessage.Attachments.Add(TheAttachment)
End If
Next
TheMailConnection.Send(TheMailMessage)
End Sub
End Class
and i am getting this error...........
Server Error in '/Email' Application.
The "SendUsing" configuration value is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.
Source Error:
Line 46: End IfLine 47: NextLine 48: TheMailConnection.Send(TheMailMessage)Line 49: End SubLine 50: End Class