|
-
Nov 2nd, 2007, 11:13 PM
#1
Thread Starter
Addicted Member
Sending an E-mail using VB 6
What is the easiest way to send an e-mail in VB 6?
The program will need to be able to send an e-mail in two different places.
The first needs to add the recipient, the sender, the subject, attach a file all with out any user interaction other than clicking a menu option in my program.
The second needs to add the recipient, the sender and the subject and allow the user to add the body and send the e-mail.
I would prefer to just use the default email program whether it be Outlook, Thunderbird Eudora etc.
Any assistance would be appreciated.
Thank you
-
Nov 2nd, 2007, 11:24 PM
#2
Re: Sending an E-mail using VB 6
you can automate outlook, but not outlook express, probably not most of the others
my choice is to use vbSendmail, do a search to download it, you can either add the class to your project, or add a reference to the dll, this will aloow you to do all requested
there are several threads in this forum about using it and is has good instructions
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 2nd, 2007, 11:39 PM
#3
Thread Starter
Addicted Member
Re: Sending an E-mail using VB 6
So do I just need to have the .dll file in the same directory as my program add? Or how does that work.
I understand about the code I need to add to my prgram. I just do not know what to do with the dll file. None of my simple programs have required a dll file to date
-
Nov 3rd, 2007, 01:33 AM
#4
Re: Sending an E-mail using VB 6
the dll needs to be registered in windows, using regsvr32, can be put into system32 directory, or in app.path
to run your program on another computer, you need to package the dll with your program
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 3rd, 2007, 10:09 AM
#5
Thread Starter
Addicted Member
Re: Sending an E-mail using VB 6
I have place the code where it needs to be in the program as described in the vbSendMail.doc file.
I have added vbSendMail.cls to my program
However when I attempt to run the program I get the follow error:
Compile Error
User defined type not defined
The compile Error is on the following line of code:
Code:
Private WithEvents poSendMail As vbSendMail.clsSendMail
-
Nov 3rd, 2007, 03:01 PM
#6
Thread Starter
Addicted Member
Re: Sending an E-mail using VB 6
I got what I wanted to work. I used the following code:
Code:
Dim OTLApp As New Outlook.Application
Dim OTLMail As Outlook.MailItem
Set OTLApp = CreateObject("Outlook.Application")
Set OTLMail = OTLApp.CreateItem(olMailItem)
With OTLMail
.To = ""
Rem .CC = ""
Rem .BCC = "
.Subject = ""
.Body = ""
.Attachments.Add
.Send
End With
-
Nov 3rd, 2007, 03:02 PM
#7
Re: Sending an E-mail using VB 6
But that will only use Outlook and none of the other email clients you mentioned.
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 
-
Nov 3rd, 2007, 05:29 PM
#8
Thread Starter
Addicted Member
Re: Sending an E-mail using VB 6
I would like it to use other programs to send the email, but I will deal with out look for know. I need to get something I can demo by Monday.
-
Nov 3rd, 2007, 05:48 PM
#9
Re: Sending an E-mail using VB 6
I have added vbSendMail.cls to my program
did you add it a a class module?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 3rd, 2007, 06:02 PM
#10
Re: Sending an E-mail using VB 6
Ok, then maybe looking at my Outlook FAQ on the subject will help.
http://vbforums.com/showthread.php?t=402083
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 
-
Nov 3rd, 2007, 07:04 PM
#11
Thread Starter
Addicted Member
Re: Sending an E-mail using VB 6
 Originally Posted by westconn1
did you add it a a class module?
On the Menu in VB I selected Add Class Module and added the vbSendMail.cls.
-
Nov 3rd, 2007, 07:26 PM
#12
Re: Sending an E-mail using VB 6
should work then i have a program like that
do you want to post your program, or make a new project and try it in that, to post if it does not work
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 3rd, 2007, 10:42 PM
#13
Thread Starter
Addicted Member
Re: Sending an E-mail using VB 6
My program is not long but their is a lot of code.
I emailed the creator of vbsendmail. I told him that I added the code to the Modular level declarations, form_Load() and the area I want the program to actually send the mail. Sory I did not on in this form just said I add the required code.
This is his response
You need to register the DLL using regsvr32.exe, then you need to add a reference to the DLL in your project. There's info in the documentation on how to do this.
Two questions about his response
#1 Do I need to register the DLL even on my computer that I am designing the program on.
#2 I did not tell him that I added the cls file to my program. Do I still need to add a reference to the dll even though the cls file is actually part of my program. I have gone through the word doc file a couple times and will a third time but I can not find were referenceing the dll is found. How is this done.
-
Nov 3rd, 2007, 11:40 PM
#14
Re: Sending an E-mail using VB 6
#1. Yes and yes.
#2. Tools > References... > check vbSendmail.dll
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 
-
Nov 3rd, 2007, 11:54 PM
#15
Re: Sending an E-mail using VB 6
if you are using the class module, you do not need the dll at all
you do need to make sure that winsock component is added to your project,if it is not already done so by the class module and that the references to the winsock from the class module are correct
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 6th, 2007, 10:19 AM
#16
New Member
Re: Sending an E-mail using VB 6
Recently I tried vbSendMail. its easy to use in the dll form. The problem is that when i tried to use it mails didn't get to destination beacause i need a smtp server. i tried with the automatic server detection included in the dll, but the server send me an internal error. can anyone help me with that? any other method for sending emails without using an ocx (preferably) or an external program (excludent) will help.
note i read about the method thru direct winsock, there i would be happy to use if someone can guide me
-
Dec 6th, 2007, 03:29 PM
#17
Re: Sending an E-mail using VB 6
does you internet service provider give you access to send and receive emails, if so you can use their smtp server to send mails, if you do not have access to a smtp server the only way to send mails would be to use a webmail component using an inet control or similar
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 6th, 2007, 03:55 PM
#18
New Member
Re: Sending an E-mail using VB 6
i tried it, and get a success answer, but the mails never get to destination.the problem is that my program is directed to be distributed amongst my clients, so i can't know which are the ISP and make it try. how about if i host an smtp server on my computer? i found some of this class of programs when i was researching, but didn't still have time to test them.
-
Dec 7th, 2007, 05:38 AM
#19
Re: Sending an E-mail using VB 6
yes you can run a smtp server, but it is not simple to set up, especially if you want to forward the emails to other domains
also many internet service providers block port 25 (default smtp port), so no outgoing emails can go except through their servers, unless the other server is using a none default port
do more research
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|