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

dude may be the problem coz u didnt add the next line to ur code.

SmtpMail.SmtpServer = "name of ur smtp server and often is localhost"

try that

sam

dude may be the problem coz u didnt add the next line to ur code.

SmtpMail.SmtpServer = "name of ur smtp server and often is localhost"

try that

sam

thank you so much. Now i am able to send mails, but the problem i noticed is that the mail is going to the BULK folder of the person whose email address i am writing in TO field, and also when i specified CC field and a email address then mail goes to the INBOX folder. What is the reason behind this.Plz.
So do you have any solution for this.

dude

ofcourse the mail will reach the bulk mail because ur server isnt known to the server u r sending the mail.

u can do the thing to make the mail goes directly to the inbox but i dont know it and i heard it fucking hard. u have to play with some protocols and other shits.
my advice to u is to be happy with wht u got.

sam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.