943,890 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 16859
  • VB.NET RSS
Jan 3rd, 2008
0

Sending email using vb.net

Expand Post »
Hi freinds
I want to send an email using VB.NET2005.
Can any one help me in it any
code??????
Similar Threads
bcm
Reputation Points: 18
Solved Threads: 0
Junior Poster in Training
bcm is offline Offline
63 posts
since Aug 2007
Jan 3rd, 2008
0

Re: Sending email using vb.net

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;

VB.NET Syntax (Toggle Plain Text)
  1.  
  2. Private Sub SendMail(ByVal sEmail As String)
  3. 'this procedure recieves an email address and sends a message.
  4. 'Dim objCDO As New CDO.Message
  5. Dim objSendMail As New CDO.Message
  6. Dim strEmailAddress As String
  7.  
  8. Try
  9. strEmailAddress = sEmail
  10. With objSendMail
  11. .From = "emailaddress@somewhere.com"
  12. .To = RTrim(strEmailAddress)
  13. '.CC = "ccemail@somewhere.com"
  14. .Subject = "Your Subject Here"
  15. .TextBody = "Put your message here"
  16. .HTMLBody = "<H3>For HTML Messages</H3>" & _
  17. "<P>Format in HTML just put everything between quotes</P>"
  18. .Send()
  19. End With
  20. Catch ex As Exception
  21. 'do your error handling here
  22. Finally
  23. objSendMail = Nothing
  24. End Try
  25.  
  26. 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.

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub sendMail(ByVal FName As String, ByVal lName As String, ByVal eMail As String)
  2. 'sends the email
  3. Try
  4. 'Open up a MAPI session
  5. Me.mapiSession.SignOn()
  6.  
  7. 'Point the MAPI messages control to the open MAPI session
  8. Me.mapiMessage.SessionID = Me.mapiSession.SessionID
  9.  
  10. 'Start a new message
  11. Me.mapiMessage.Compose()
  12.  
  13. With Me.mapiMessage
  14. .MsgSubject = "Your Subject"
  15. .MsgReceiptRequested = True
  16. .MsgNoteText = "This is the message."
  17. .RecipType = 1
  18. .RecipAddress = eMail
  19. .Action = 13
  20. .Send(False)
  21. End With
  22.  
  23. 'sign off of the session
  24. Me.mapiSession.SignOff()
  25.  
  26. 'increase the mail count
  27. Me.mintSent += 1
  28.  
  29. Catch ex As Exception
  30. MessageBox.Show(ex.Message)
  31. End Try
  32. End Sub
Last edited by emurf; Jan 3rd, 2008 at 12:53 pm.
Reputation Points: 12
Solved Threads: 4
Light Poster
emurf is offline Offline
37 posts
since Nov 2007
Jan 6th, 2008
0

Re: Sending email using vb.net

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
teopohkuang is offline Offline
1 posts
since Jan 2008
Jan 6th, 2008
0

Re: Sending email using vb.net

Click to Expand / Collapse  Quote originally posted by bcm ...
Hi freinds
I want to send an email using VB.NET2005.
Can any one help me in it any
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/SourceCo...spx?SourceID=2
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Jan 6th, 2008
0

Re: Sending email using vb.net

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?
Last edited by emurf; Jan 6th, 2008 at 12:10 pm.
Reputation Points: 12
Solved Threads: 4
Light Poster
emurf is offline Offline
37 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: sry for asking this but...
Next Thread in VB.NET Forum Timeline: Forms





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC