954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sending email using vb.net

Hi freinds
I want to send an email using VB.NET2005.
Can any one help me in it any :icon_redface:
code??????

bcm
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 18
Solved Threads: 0
 

Try using Microsoft's CDO control. Finding it may be a head ache since there are a bunch of different versions. I think that I was using 6.5 when I wrote this;

Private Sub SendMail(ByVal sEmail As String)
        'this procedure recieves an email address and sends a message.
        'Dim objCDO As New CDO.Message
        Dim objSendMail As New CDO.Message
        Dim strEmailAddress As String

        Try
            strEmailAddress = sEmail
            With objSendMail
                .From = "emailaddress@somewhere.com"
                .To = RTrim(strEmailAddress)
                '.CC = "ccemail@somewhere.com"
                .Subject = "Your Subject Here"
                .TextBody = "Put your message here"
                .HTMLBody = "<H3>For HTML Messages</H3>" & _
                            "<P>Format in HTML just put everything between quotes</P>"
                .Send()
            End With
        Catch ex As Exception
            'do your error handling here
        Finally
            objSendMail = Nothing
        End Try

End Sub


CDO.dll came with Outlook Pro prior to the 2007 version (I don't know if it ships with 2007). If you don't have it you should be able to find it by searching http://msdn.microsoft.com .

Another way is to add a MAPI control to your project. I've only did this in one project but I hear that it is best with VB .NET 2005. This is what I wrote.

Private Sub sendMail(ByVal FName As String, ByVal lName As String, ByVal eMail As String)
        'sends the email
        Try
            'Open up a MAPI session
            Me.mapiSession.SignOn()

            'Point the MAPI messages control to the open MAPI session
            Me.mapiMessage.SessionID = Me.mapiSession.SessionID

            'Start a new message
            Me.mapiMessage.Compose()

            With Me.mapiMessage
                .MsgSubject = "Your Subject"
                .MsgReceiptRequested = True
                .MsgNoteText = "This is the message."
                .RecipType = 1
                .RecipAddress = eMail
                .Action = 13
                .Send(False)
            End With

            'sign off of the session
            Me.mapiSession.SignOff()

            'increase the mail count
            Me.mintSent += 1

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
emurf
Light Poster
37 posts since Nov 2007
Reputation Points: 12
Solved Threads: 4
 

recently i was faced a problem to update, insert and delete the data from the table by using vb.net code, can u help me to solve the problem.

teopohkuang
Newbie Poster
1 post since Jan 2008
Reputation Points: 10
Solved Threads: 1
 
Hi freinds I want to send an email using VB.NET2005. Can any one help me in it any :icon_redface: code??????

Hi,
If you want to send E-Mails without Outlook installed then you might want to use VB.NETs SMTP code

Try this: http://www.taylorsnet.co.uk/SourceCodeDetail.aspx?SourceID=2

ptaylor965
Junior Poster
170 posts since Oct 2006
Reputation Points: 16
Solved Threads: 19
 

Teopohkuang; I can help but can you create a new thread with your question, include as much detail about your problem as you can describe, so that others with similar problems can more easily find it?

emurf
Light Poster
37 posts since Nov 2007
Reputation Points: 12
Solved Threads: 4
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You