• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 655
  • Last Modified:

send email from vb.net code

send email from vb.net code
send email from vb.net code

Open in new window

0
doaa_
Asked:
doaa_
1 Solution
 
isaackhaziCommented:
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)
0
 
vigylantCommented:
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

0
 
isaackhaziCommented:
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

0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
isaackhaziCommented:
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

0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
war1Commented:
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
0
 
war1Commented:
Sorry, I posted my last comment in wrong question.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now