We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

send email from vb.net code

Medium Priority
709 Views
Last Modified: 2012-05-06
send email from vb.net code
send email from vb.net code

Open in new window

Comment
Watch Question

http://www.jscape.com/articles/sending_email_using_vb.html

links contains all the steps to send emails using VB.NET (i think its c# but can easily be converted)
Commented:
Simple example:
        Dim MSG As New System.Net.Mail.MailMessage("FROM", "TO", "SUBJECT", "BODY")
        Dim SMTP As New System.Net.Mail.SmtpClient("your.host", 25)
        SMTP.Send(MSG)

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Method 1
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

Open in new window

Method 2
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

Open in new window

Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016

Commented:
CERTIFIED EXPERT
Top Expert 2008

Commented:
Hello globaloffice,

1. Check if Outlook is in Offline mode. In Outlook go to File and make sure Work Offline is not selected.

2. Register an important send/receive library file.  Go to Start > Run and type regsvr32 inetcomm.dll

3. Check if antivirus email check is slowing sending and receiving.  Disable it. Check if other programs running in the background is interfering. Disable one at a time the Firewall, antispyware, antispam, and all Norton programs.

4. In the account settings, Advanced settings, change the server timeout time from 1 min to 5 min

5. Check if outgoing mail server authentication is required. Select that option in account settings and use same settings as incoming server

6. Your ISP may be blocking port 25. Try using alternate port 587.

If no joy, you need to use your ISP SMTP server to send out emails.

7. Create a new Outlook profile.
http://www.outlook-tips.net/howto/profile.htm

8.  Check with email provider Tech Support to determine if server is having trouble.

Hope this helps!
war1
CERTIFIED EXPERT
Top Expert 2008

Commented:
Sorry, I posted my last comment in wrong question.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.