Sending email using vb.net

Thread Solved

Join Date: Aug 2007
Posts: 63
Reputation: bcm is an unknown quantity at this point 
Solved Threads: 0
bcm's Avatar
bcm bcm is offline Offline
Junior Poster in Training

Sending email using vb.net

 
0
  #1
Jan 3rd, 2008
Hi freinds
I want to send an email using VB.NET2005.
Can any one help me in it any
code??????
BCM
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 37
Reputation: emurf is an unknown quantity at this point 
Solved Threads: 4
emurf emurf is offline Offline
Light Poster

Re: Sending email using vb.net

 
0
  #2
Jan 3rd, 2008
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;

  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.

  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 11:53 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 1
Reputation: teopohkuang is an unknown quantity at this point 
Solved Threads: 1
teopohkuang teopohkuang is offline Offline
Newbie Poster

Re: Sending email using vb.net

 
0
  #3
Jan 6th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Sending email using vb.net

 
0
  #4
Jan 6th, 2008
Originally Posted by bcm View Post
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
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 37
Reputation: emurf is an unknown quantity at this point 
Solved Threads: 4
emurf emurf is offline Offline
Light Poster

Re: Sending email using vb.net

 
0
  #5
Jan 6th, 2008
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 11:10 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum


Views: 9994 | Replies: 4
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC