| | |
Sending email using vb.net
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 37
Reputation:
Solved Threads: 4
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;
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)
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
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)
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
Last edited by emurf; Jan 3rd, 2008 at 11:53 am.
•
•
•
•
Hi freinds
I want to send an email using VB.NET2005.
Can any one help me in it any![]()
code??????
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
![]() |
Similar Threads
- Sending email from a shell script (Shell Scripting)
- sending sms using vb.net (VB.NET)
- Sending HTML/Plain text Emails (PHP)
- Auto Mail in ASP.NET (ASP.NET)
- Help...symantec keeping sending email (Viruses, Spyware and other Nasties)
- 62.214.197.166 wants to send email through java (Viruses, Spyware and other Nasties)
- email mail deliver error?? virus? (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: sry for asking this but...
- Next Thread: Forms
Views: 9994 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access ado.net application array arrays basic bindingsource browser c# center checkbox client code combobox connection control convert crystal crystalreport data database datagrid datagridview dataset datatable date datetimepicker design designer dissertation dissertations error excel file filter form gridview image images insert installer listview login loops mobile ms msaccess net objects openxml path picturebox port print printing problem read save search security serial server settings shutdown sms socket sorting sql statement studio syntax tagging tags textbox time timer type update upload user validation vb vb.net vb2008 view visual visual-studio visualbasic visualstudio2008 vs2008 web webbrowser windows winforms wpf xml





