dear all
I am trying to send a mail using Web.Mail in vb.net. It is working fine but when I try to attach the file using Upload File Control of asp.net, event is not getting fired on which the function is getting called to send mail..
sending the code too. Please help me out.

Public Sub SendMail(ByVal _To As String, ByVal _cc As String, ByVal _Bcc As String, _
                        ByVal Name As String)
        Try
            Dim _Path As String = "E:\Websites\Sales_Production\DefaultDir\Attachment"
            Dim msg As String = ""
            Dim oAttach As MailAttachment
            Dim objMail As New MailMessage()

            '_Path = Path.GetFullPath(UploadFile.PostedFile.FileName)
            Try
                oAttach = New MailAttachment(_Path)
            Catch ex As Exception

            End Try

            With objMail
                .To = _To '"akash@idspl.com" 
                .Cc = "vishal@idspl.com" '_cc
                .Bcc = _Bcc
                .From = "support@idspl.com"
                .Subject = "No Reply: SR mail from CRM-Web."
                .Body = txtBody.Text
                .BodyFormat = MailFormat.Html
                .Attachments.Add(oAttach)
            End With

            Try
                oAttach = New MailAttachment(_Path)
                objMail.Attachments.Add(oAttach)
            Catch ex As Exception
                lblBCC.Text = ex.Message
            End Try
            SmtpMail.SmtpServer = "192.168.1.4"
            SmtpMail.Send(objMail)

        Catch ex As Exception
            Msg = ex.Message
            MsgBox(Msg)
        End Try
    End Sub

Probably a silly question but does your FileUpload control have run at server in the html file?

Probably a silly question but does your FileUpload control have run at server in the html file?

yes it has RUNAT server property already set.. but event is not getting fired up..

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.