Sending Email

Look into the System.Web.Mail namespace:

[mshelp]ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebMail.htm[/mshelp]
 
sending outlook emailes!

I want to send outlook eamiles by using vb.net through my application.
 
This is what I use:

Visual Basic:
     Try
            Dim olNameSpace As Outlook.NameSpace
            Dim objOutlook As Outlook.Application
            Dim objNewMail As Outlook.MailItemClass

            ' create an outlook mail message

            objOutlook = New Outlook.Application()
            objOutlook.Session.Logon(NewSession:=False)
            olNameSpace = objOutlook.GetNamespace("MAPI")
            objNewMail = objOutlook.CreateItem(Outlook.OlItemType.olMailItem)

            ' format the body of the message

            strBody = gstrApplicationName & " has generated the following error: " & vbCrLf & vbCrLf & strBody & _
                      vbCrLf & vbCrLf & "Please contact this user as soon as possible"

            ' finalise message detail then send

            With objNewMail

                .To = gstrRecipient
                .Recipients.ResolveAll()
                .Subject = gstrSubject
                .Body = strBody
                .Send()

            End With

        Catch objException As Exception

            System.Windows.Forms.MessageBox.Show("An error has occured whilst attempting to send the email" & _
                                                 ControlChars.CrLf & ControlChars.CrLf & "If the problem persists " & _
                                                 "please contact the System Administrator", "pjhError.dll ~ Error", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Error)

        End Try

you need to reference Interop.Outlook.dll for this to work.

[edit]Yes it is [vb][/vb][/edit]
 
Last edited by a moderator:
Back
Top