You are on page 1of 10

See More About:

Ads

email smtp outlook

Download Google ChromeSearching is fast and easy with Google's web browser.www.Google.com/Chrome Email Large Folders FastEmail, Receive & Track Files Up To 2 GB Without An FTP. Try It Free!YouSendIt.com/Email-Large-Folders Send Mail from ASP / .NETAspEmail supports Unicode, HTML, encryption, TLS, message queuing.www.aspemail.com

Question: How do I use Visual Basic to access the HTML code of a website?
The easiest way to do this in VB6 is probably to use the Microsoft MAPI control. MAPI is Messaging Application Programming Interface. Add this to your VB6 project by clicking Project from the top menu, then select Components. Scroll down the list until you find the Microsoft MAPI controls and click the check box to add it. Using the MAPI control involves two steps: 1. Establishing a MAPI session 2. Using MAPI properties and methods With the MAPI component, you can create and send a message, include a file attachment, verify the recipient's email address against the email system's address book and lots more. For example, this statement (with the proper supporting code) can sign on to a MAPI Session.
MAPISession1.SignOn

VB.NET EMail
In VB.NET, you can do essentially the same thing (but with more power and flexibility) using System.Net.Mail. The MailMessage class in that namespace represents the content of a mail message. The SmtpClient class transmits email to an SMTP host and you can create mail attachments using the Attachment class. You can find example code at Microsoft's MSDN site. These objects will probably do the job for you, but if you need to go to a lower level, search for SMTP, the Simple Mail Transfer Protocol, and POP3, the Post Office Protocol version 3. An alternative way to do the job is to take advantage of the Microsoft Outlook objects using automation. Add a Reference to the Microsoft Outlook object library to your VB.NET project. Using this method, the Microsoft.Office.Interop.Outlook.Application class represents the entire application, the MAPIFolder class represents a folder that contains e-mail messages or other items, and the MailItem class represents an e-mail message See More About:

email smtp outlook

Ads

Download Google ChromeSearching is fast and easy with Google's web browser.www.Google.com/Chrome Email Large Folders FastEmail, Receive & Track Files Up To 2 GB Without An FTP. Try It Free!YouSendIt.com/Email-Large-Folders Send Mail from ASP / .NETAspEmail supports Unicode, HTML, encryption, TLS, message queuing.www.aspemail.com

Question: How do I useVisual Basic to access the HTML code of a website?


The easiest way to do this in VB6 is probably to use the Microsoft MAPI control. MAPI is Messaging Application Programming Interface. Add this to your VB6 project by clicking Project from the top menu, then select Components. Scroll down the list until you find the Microsoft MAPI controls and click the check box to add it. Using the MAPI control involves two steps: 1. Establishing a MAPI session 2. Using MAPI properties and methods With the MAPI component, you can create and send a message, include a file attachment, verify the recipient's email address against the email system's address book and lots more. For example, this statement (with the proper supporting code) can sign on to a MAPI Session.
Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Sub Command1_Click() Call ShellExecute(0&, vbNullString, "Mailto:" & "s.deepak150@gmail.com", vbNullString, vbNullString, vbNormalFocus) End Sub Private Sub label1_Click() With Label1 .Drag vbBeginDrag End With End Sub Private Sub label1_DragDrop(Source As Control, X As Single, Y As Single) If Source Is Label1 Then With Label1 ' Call ShellExecute(0&, vbNullString, "Mailto:" & .Caption, vbNullString, vbNullString, vbNormalFocus)

End With End If End Sub 'VB.NET

EMail

In VB.NET, you can do essentially the same thing (but with more power and flexibility) using System.Net.Mail. The MailMessage class in that namespace represents the content of a mail message. The SmtpClient class transmits email to an SMTP host and you can create mail attachments using the Attachment class. You can find example code at Microsoft's MSDN site. These objects will probably do the job for you, but if you need to go to a lower level, search for SMTP, the Simple Mail Transfer Protocol, and POP3, the Post Office Protocol version 3. An alternative way to do the job is to take advantage of the Microsoft Outlook objects using automation. Add a Reference to the Microsoft Outlook object library to your VB.NET project. Using this method, the Microsoft.Office.Interop.Outlook.Application class represents the entire application, the MAPIFolder class represents a folder that contains e-mail messages or other ites, and the MailItem class represents an e-mail message

----------------------------------------------------------------------

You are here:


Home Computing/Technology Basic Visual Basic sending email within vb 6.0

Visual Basic/sending email within vb 6.0


Advertisement Expert: Pat Murphy - 10/20/2004
Question Hello, the goal is to send an automated email through vb app in the middle of the night without anyone present. If the outlook object is used, an 'are you sure' message

pops up if the user has outlook version 10. And if no one is present to answer the question, the email does not get sent. I have tried 3rd party software, simple to use, but more overhead in the project. What other objects/references in vb can I use to connect to an email server, and send email without using the outlook control? I have heard of MAPI but it is not an option in 'references' or 'components'. Where can I download the .ocx for this and what are its properties? Or is there another way to smtp? thanks Get the answer below
Sponsored Links

OpenLink VirtuosoHybrid Database Server for SQL, XML, RDF, and Free Textvirtuoso.openlinksw.com/ Getting Files Via FTPSend Large Files Without FTP. Join Over 30 Million Users! Try it FreeYouSendIt.com/Get-Files-Via-FTP M2M Web Databasefor dezentralized sites, 56k,GSM wide range PLC supportwww.tixi.com
Answer I found Code for Winsock! 'Create a blank/normal form. Make sure that the MSWINSCK.OCX is loaded in the toolbar also. After that, l'oad the Winsock control onto the form, and one Command button. 'Add this code to the General Declaration of the form. 'These are the variables I use in the heart of the SMTP sub. Dim Response As String Dim Reply As Integer Dim DateNow As String Dim first As String Dim Second As String Dim third As String Dim Fourth As String Dim Fifth As String Dim Sixth As String Dim Seventh As String Dim Eighth As String 'Add this code below to the Winsock1_DataArrival Event Winsock1.GetData Response 'After that you'll add this code to the General Declarations area of the form/module. ' This is one of two subs that will wait for the SMTP server to 'return the appropriate return code before the SMTP sub can proceed to send any

mail. Sub WaitFor(ResponseCode As String) Dim tmr As Long While Len(Response) = 0 DoEvents If tmr > 50 Then MsgBox "SMTP service error, unable to get a response1", 64, MsgTitle Exit Sub End If Wend While left(Response, 3) <> ResponseCode DoEvents If tmr > 50 Then MsgBox "SMTP service error, unable to get a response2", 64, MsgTitle Exit Sub End If Wend End Sub This Next Sub Is the one which contains the flaw. See what happens Is 'right after I send the data, I get a string which needs to be parsed for the 'error code but for some reason Instr doesn't work, I'll appreciate it anyone can shed some light on this. Sub WaitFor2(ResponseCode As String) Dim tmr As Long tmr = Timer While Len(Response) = 0 If tmr > 50 Then MsgBox "SMTP service error, unable to get a response3", 64, MsgTitle Exit Sub End If Unload Techsup DoEvents Wend 'Reply = InStr(Response, "354 ") While Reply = 0 Reply = InStr(Response, ResponseCode) DoEvents Wend End Sub Here Is the heart of the SMTP Sub. It has a few arguments before you can send any mail. 'One problem you might encounter is that you have to find a mail server that will let

you send email, 'you could use your ISP's mailserver but that requires for you to be logged on to that account. Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String) DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(time, "hh:mm:ss") & " " & " -0600" first = "mail from:" + Chr(32) + FromEmailAddress + vbCrLf Second = "rcpt to:" + Chr(32) + ToEmailAddress + vbCrLf third = "Date:" + Chr(32) + DateNow + vbCrLf Fourth = "From:" + Chr(32) + FromName + vbCrLf Fifth = "To:" + Chr(32) + ToName + vbCrLf Sixth = "Subject:" + Chr(32) + EmailSubject + vbCrLf Seventh = EmailBodyOfMessage + vbCrLf Ninth = "X-Mailer: DevPatch Tech Support Form" + vbCrLf Eighth = Fourth + third + Ninth + Fifth + Sixth + Seventh Winsock1.Protocol = sckTCPProtocol Winsock1.RemoteHost = MailServerName Winsock1.RemotePort = 25 Winsock1.Connect WaitFor ("220") Winsock1.SendData ("HELO iessoft.com" + vbCrLf) WaitFor ("250") Winsock1.SendData (first) WaitFor ("250") Winsock1.SendData (Second) WaitFor ("250") Winsock1.SendData ("data" + vbCrLf) WaitFor2 ("354 ")

Winsock1.SendData (Eighth) Winsock1.SendData ("." + vbCrLf)

WaitFor ("250") Winsock1.SendData ("quit") WaitFor ("221") Winsock1.Close End Sub 'Finally, you can put this code in the Command1_Click event. SendEmail "yourserver.com", "yourname", "sk@iessoft.com", "Shafayat Kamal", "youraddress@xyz.com", "Winsock SMPT test", "Hello!" & chr(10) 'When you run this project everything should run fine, however, 'I suggest trying to send mail to yourself to you can debug the 'SMTP sub to suit your needs. Questioner's Rating Rating(1 Knowledgeability = 10 -10) Clarity of Response = 10 Politeness = 10

Pat - As an amateur it took me a fewe minutes to figure out what Commen lines of code in your example you intended for me to use. But once i t got it sorted out, IT WORKS! frankfreeland@yahoo.com

Add to this Answer Ask a Question Displaying HTML Documents Using Internet Explorer Using ADO .NET - Access and OleDB Part 2 Compiling Regular Expressions StringBuilder ... A New Object in .NET Procedures in VB.NET

Related Articles

Sponsored Links

"Heart Attack Warning"Clean Arteries Before Surgery. Painless, Fast, Safe & Easywww.YourTicker.com/Angioprim Sql Server ServerMicrosoft Private Cloud Solutions Full Control Down to the App Level.www.microsoft.com/Private_Cloud AspEncrypt ComponentData encryption, secure mail, certs, digital signatures for ASPwww.aspencrypt.com
Visual Basic Ads

Visual Basic VB 6 to VB Net Sending Email VB Source Code VB Visual Basic

All Answers Answers by Expert:


Robert Nunemaker Amal Raj A Frank G. Dahncke VITALY Golfnut_1969 Ravindra Richard Rost Kevin Watkins Kaustav Neogy Ahmed Sayed Aziz

Ask Experts Volunteer


Pat Murphy
Expertise

I can answer Advanced Visual Basic Questions, integration with Office (Word, Excel, even Outlook, ADO, ASP, DAO, database (Access/Oracle/SQL Server) including stored procedures.
Experience

About 14 years VB experience 10 of those with databases Access/Oracle/SQL Server.

User Agreement Privacy Policy

Encyclopedia

2012 About.com, a part of The New York Times Company. All rights reserved.
About Us Tell Friends

How to Ask How to Volunteer FAQ Tech Support Top Experts Expert Login

Browse Answers:
By Category Alphabetically
Top of Form

Bottom of Form

-------------------------------------------------------------------------------------------------Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Sub Command1_Click() Call ShellExecute(0&, vbNullString, "Mailto:" & "s.deepak150@gmail.com", vbNullString, vbNullString, vbNormalFocus) End Sub Private Sub label1_Click() With Label1 .Drag vbBeginDrag End With End Sub Private Sub label1_DragDrop(Source As Control, X As Single, Y As Single) If Source Is Label1 Then With Label1 ' Call ShellExecute(0&, vbNullString, "Mailto:" & .Caption, vbNullString, vbNullString, vbNormalFocus)

End With End If End Sub '

You might also like