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
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
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
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
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
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
Re: Sending an E-mail using VB 6
But that will only use Outlook and none of the other email clients you mentioned.
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.
Re: Sending an E-mail using VB 6
Quote:
I have added vbSendMail.cls to my program
did you add it a a class module?
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
Re: Sending an E-mail using VB 6
Quote:
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.
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
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
Quote:
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.
Re: Sending an E-mail using VB 6
#1. Yes and yes.
#2. Tools > References... > check vbSendmail.dll
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
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
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
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.
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