0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
2
Replies
9
Views
7 Years
Discussion Span
Last Post by vvashishta
-1

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

0

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..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.