|
-
Feb 12th, 2006, 03:57 PM
#1
Thread Starter
Lively Member
help nid perfect code for sending email with vb6
can someone tell me what are the codes, objects, and controls to use for sending email with visual basic or can someone tell me where can i download a perfect example application of a visual basic that can send email.
if someone post a code, tell me what is the used of the code and how the code works and what are the things that i should know if i want to create my own vb application that can send email.
thanks in advance!!!!!!!!
sori for my poor english
-
Feb 12th, 2006, 04:03 PM
#2
Re: help nid perfect code for sending email with vb6
-
Feb 12th, 2006, 04:09 PM
#3
Frenzied Member
Re: help nid perfect code for sending email with vb6
You can use the ShellExecute function, which uses MS Outlook
VB Code:
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 Const SW_SHOWNORMAL As Long = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, "Open", "mailto: [email protected]?Subject=My Email Title Goes Here", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
-
Feb 13th, 2006, 11:21 AM
#4
Re: help nid perfect code for sending email with vb6
That actually should use whatever your default mail service is, not just Outlook.
-
Feb 13th, 2006, 12:28 PM
#5
Re: help nid perfect code for sending email with vb6
Yes and the one drawback is the limitation of characters in the lpFile argument and adding attachments issue with certain characters. For simple email generation its greeat though.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 13th, 2006, 01:29 PM
#6
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
 Originally Posted by wiz126
You can use the ShellExecute function, which uses MS Outlook
VB Code:
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 Const SW_SHOWNORMAL As Long = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, "Open", "mailto: [email protected]?Subject=My Email Title Goes Here", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
thanks for this example but when i try to run this program ms outlook will open, the code i want is the code which can send e mail without using any other program like ms outlook,
for example
when i click a command button an e-mail message will be send automatically to my emaill add. my question is what are the codes im going to use to the command button so that when i click the command button an email message will be send to my e mail address.
sorry for my poor english!!!
thanks for your replies
thanks in advance !!!!
-
Feb 13th, 2006, 01:33 PM
#7
Re: help nid perfect code for sending email with vb6
Search for SMTP on the forums and you will find the code necessary.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 13th, 2006, 01:41 PM
#8
Re: help nid perfect code for sending email with vb6
The only control you need is the micorosft winsock control, you will find info about this contorl in the network programming section of the vb forums.
So you need to learn how to use winsock to make a connection to a server and send/receive data, then you need to learn the SMTP protocol which is used to send email.
The you can connect to the SMTP server with winsock and use your knowledge of the SMTP protocol to send the mail message.
You will find a lot of info about SMTP on google, the best thing to look for is example sessions, you will learn the protocol very quickly by looking at these.
Note: You will need a mail server to send your emails, i would recommend using your internet service providers mail server, this will put your email address in the from field.
Chris
-
Feb 13th, 2006, 02:11 PM
#9
Frenzied Member
Re: help nid perfect code for sending email with vb6
VB Code:
'Add to references:
'Microsoft CDO for Windows 2000 library
'Microsoft ActiveX Library 2.x
Dim oConfig As CDO.Configuration
Dim oMessage As CDO.Message
Dim oFields As ADODB.Fields
Set oConfig = CreateObject("CDO.Configuration")
Set oFields = oConfig.Fields
With oFields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.yourServer.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "Username"
.Item(cdoSendPassword) = "Password" ' If required
.Update
End With
Set oMessage = CreateObject("CDO.Message")
Set oMessage.Configuration = oConfig
With oMessage
.Subject = "Test mail"
.TextBody = "Test mail"
' .AddAttachment "c:\test.doc"
.Send
End With
oh1mie/Vic

-
Feb 14th, 2006, 12:50 AM
#10
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
thanks for all the reply
 Originally Posted by oh1mie
VB Code:
'Add to references:
'Microsoft CDO for Windows 2000 library
'Microsoft ActiveX Library 2.x
Dim oConfig As CDO.Configuration
Dim oMessage As CDO.Message
Dim oFields As ADODB.Fields
Set oConfig = CreateObject("CDO.Configuration")
Set oFields = oConfig.Fields
With oFields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.yourServer.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "Username"
.Item(cdoSendPassword) = "Password" ' If required
.Update
End With
Set oMessage = CreateObject("CDO.Message")
Set oMessage.Configuration = oConfig
With oMessage
.Subject = "Test mail"
.TextBody = "Test mail"
' .AddAttachment "c:\test.doc"
.Send
End With
'Microsoft ActiveX Library 2.x ---> why cant i see this in my references and
'Microsoft ActiveX data object Library 2.x---> this are the things i saw in the reference shouk i yse this reference
another thing can i use this code i am using windows xp
sorry for my poor english
-
Feb 14th, 2006, 01:57 AM
#11
Frenzied Member
Re: help nid perfect code for sending email with vb6
Sorry, I meant Microsoft ActiveX data object Library 2.x - shortly "ADO"
No mather if you using XP. You can still use that another library.
oh1mie/Vic

-
Feb 14th, 2006, 02:12 PM
#12
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
sir thanks for the reply, i've tried to use that code but i get an error message
run-time error `2147220975(80040211
The message could not be sent to the SMTP server. The transport error code was 0x80040217. the server response was not available.
and another thing again should i use other control like mapi control or a class module?
i put those code under command button
-
Feb 14th, 2006, 05:07 PM
#13
Frenzied Member
Re: help nid perfect code for sending email with vb6
 Originally Posted by makmaks
sir thanks for the reply, i've tried to use that code but i get an error message
run-time error `2147220975(80040211
The message could not be sent to the SMTP server. The transport error code was 0x80040217. the server response was not available.
and another thing again should i use other control like mapi control or a class module?
i put those code under command button
What is smtp server on your email count now?
Put same serveraddress here:
VB Code:
.Item(cdoSMTPServer) = "smtp.yourServer.com"
oh1mie/Vic

-
Feb 15th, 2006, 03:16 AM
#14
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
is this correct ?
.Item(cdoSMTPServer) = "smtp.mail.yahoo.com" --> for my yahoo account
.Item(cdoSMTPServer) = "smtp.mail.hotmail.com" --> hotmail
thanks again
-
Feb 15th, 2006, 03:45 AM
#15
Frenzied Member
Re: help nid perfect code for sending email with vb6
 Originally Posted by makmaks
is this correct ?
.Item(cdoSMTPServer) = "smtp.mail.yahoo.com" --> for my yahoo account
.Item(cdoSMTPServer) = "smtp.mail.hotmail.com" --> hotmail
thanks again
No, try
smtp.yahoo.com or mail.yahoo.com
oh1mie/Vic

-
Feb 15th, 2006, 08:35 AM
#16
Addicted Member
Re: help nid perfect code for sending email with vb6
Hello,
I was looking for this sort of code. So I tried the one given by oh1mie, it is showing runtime error 214722093 (80040213). Should I change any settings in the control panel?
Thank you.
-
Feb 15th, 2006, 12:06 PM
#17
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
thanks for the reply
sir oh1mie i tried this
smtp.yahoo.com or mail.yahoo.com
but i still get an error message
Run time error 214722093 (80040213).
the transport failed to connect to server
thanks again!!!!
-
Feb 15th, 2006, 12:38 PM
#18
Re: help nid perfect code for sending email with vb6
The issue may be that you dont have CDO 1.21 installed on your system. It is installed as an optional item when installing Outlook.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2006, 01:08 PM
#19
Frenzied Member
Re: help nid perfect code for sending email with vb6
Every country have own rules.
Here we use allways ISP's smtp server.
You probably have cdo, if you did find it to the references
oh1mie/Vic

-
Feb 15th, 2006, 01:19 PM
#20
Re: help nid perfect code for sending email with vb6
 Originally Posted by oh1mie
Every country have own rules.
Here we use allways ISP's smtp server.
You probably have cdo, if you did find it to the references
Your country has a law against interacting with an SMTP server other than your Internet Service Provider? I must look that one up...thats like the law in USA where you can't keep a horse in your bathtub..lol - not that i do that
-
Feb 15th, 2006, 01:21 PM
#21
Re: help nid perfect code for sending email with vb6
More then likely youll have to authenticate so you will need an account. This in turn will limit your use or prohibit it since companies like yahoo dont let you use their servers for anything other the "normal" use.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2006, 01:29 PM
#22
Frenzied Member
Re: help nid perfect code for sending email with vb6
 Originally Posted by the182guy
Your country has a law against interacting with an SMTP server other than your Internet Service Provider? I must look that one up...thats like the law in USA where you can't keep a horse in your bathtub..lol - not that i do that 
I have my own exchange smtp server, but for this practice is perhaps reason spam and virus writers. It's not a law.
oh1mie/Vic

-
Feb 15th, 2006, 02:00 PM
#23
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
 Originally Posted by RobDog888
The issue may be that you dont have CDO 1.21 installed on your system. It is installed as an optional item when installing Outlook.
why would it become an issue
actually i have cdo 1.21 installed in mine
thanks again for all your post
-
Feb 15th, 2006, 03:23 PM
#24
Re: help nid perfect code for sending email with vb6
I didnt know if you had it or no, but since you do then its not an isue.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2006, 03:35 PM
#25
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
 Originally Posted by RobDog888
I didnt know if you had it or no, but since you do then its not an isue.
ah ok
thanks for the reply
i thought i nid the cdo 1.21 control to run the program
thanks again for all the reply!!!
-
Feb 15th, 2006, 03:40 PM
#26
Re: help nid perfect code for sending email with vb6
You need it for the code example in post #9 but you can also just use pure SMTP but you need access to a SMTP server.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2006, 03:44 PM
#27
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
sorry for the double reply but pls can you edit this for me
visual basic code:-------------------------------------------------------------------------------- 'Add to references:
'Microsoft CDO for Windows 2000 library
'Microsoft ActiveX Library 2.x
Dim oConfig As CDO.Configuration
Dim oMessage As CDO.Message
Dim oFields As ADODB.Fields
Set oConfig = CreateObject("CDO.Configuration")
Set oFields = oConfig.Fields
With oFields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.yourServer.com" ---->example of this in hotmail cause i cant do it with yahoo
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "Username" --->is this the username of ".from"
.Item(cdoSendPassword) = "Password" ' If required ---->
.Update
End With
Set oMessage = CreateObject("CDO.Message")
Set oMessage.Configuration = oConfig
With oMessage
.To = "[email protected]"
.From = "[email protected]" are this example is correct
.Subject = "Test mail"
.TextBody = "Test mail"
' .AddAttachment "c:\test.doc"
.Send
End With
thanks again !!!!
sorry for my poor english
-
Feb 15th, 2006, 03:47 PM
#28
Re: help nid perfect code for sending email with vb6
You can edit your own posts. Add the [vbcode] tags and it will format it.
The user name is the account username that you should have that gives you access to your email account, but usually they dont let you use their servers to send out much mail for anything other then personal connunications, etc..
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 15th, 2006, 04:01 PM
#29
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
ah ok thanks so iis that means that i cannot use yahoo or hotmail for this and i should search another server that can let me any email message i want?
thank you veru much for all the reply!!!!
sorry for my poor english
-
Feb 15th, 2006, 04:03 PM
#30
Re: help nid perfect code for sending email with vb6
Yes, that is correct. Most ISPs have stuff in place to prevent their servers from being used for mail nodes since it can be used to send out tons of spam and place ridicules amounts of load on their servers.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 17th, 2006, 11:14 PM
#31
Thread Starter
Lively Member
Re: help nid perfect code for sending email with vb6
can i use this so called QK SMTP Server
QK SMTP Server is a powerful but extremely easy-to-use smtp server software, which can send mails from local host to the recipients' mailboxes directly at an amazingly high speed. Arrived or not, you will get feedback instantly.
can i use that as a smtp server to send email using visual basic
thanks!!!
sorry for my poor english
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|