# vbSendMail -- convert for ActiveX usage



## asbo (Sep 21, 2001)

Ok, inder the direction of TimCottee, I have downloaded the vbSendMail DLL, only to find that that code provided in the documentation is not compatiable with the ActiveX components. Can anyone help me here?? The DLL is available at http://www.freevbcode.com/ShowCode.Asp?ID=109

Thanks _again_


----------



## IMM (Feb 1, 2002)

From their docs:
---------------------------
If you get the error "Run time error 429: ActiveX component can't create object" when you run your application, the vbSendMail.dll either is not installed or not properly registered. Verify that the file is installed and manually run regsvr32.exe to register the dll. If you get a "LoadLibrary ("vbSendMail.dll") failed" message, check for a missing or incorrect version of the mswinsck.ocx. It has been reported that in some rare cases, manually registering the component does not resolve this issue. In those cases, building an installation package with the Package and Deployment Wizard, has solved the problem
--------------------------
You are using VB6 and not vb5? If vb6 what service pack level?
What version of mswinsock.ocx do you have?

You did register it with regsvr32 ??
c:\windows\system\RegSvr32.Exe &nbsp;&lt;Path&gt;\vbSendMail.Dll 

What exactly is the error message??


----------



## asbo (Sep 21, 2001)

Ok, heres where I stand:

_*This is designed to work on a webpage*_

I created my project, and later a module to go with the vbSendMail function, and when I add the code

Private WithEvents poSendMail As vbSendMail.clsSendMail

and run, it returns the error:

Compile Error:

User-type not defined.

Everything else appears to work fine, but I am unable to get past this, and I am not sure even why this comes up.

*cough* *cough* newby



In response to your post IMM, my version of VB6 is same as install level, what ever that, I suppose SP0 . As for registering it with the system, I see no point because this is, as mentioned above, supposed to work on a webpage, and if I can get it to work without any shimnanigans, all for the better. And, according Windows, mswinsock.dll does not exist. Unless I can be guarunteed that all of the visitors will have this, I'd really hope to find some alternate way of using it, hosting it at the site, maybe.

Please forgive me for anything that is blantly not possible, I do not have much experience with internet-related programming, in fact, I have none before this.


----------



## TimCottee (Oct 10, 2001)

asbo:

You generally need to register an activex dll with the system on which it is going to run. Now there is an exception to this in that you can just include the dll in the same folder as the application's executable and it will be found without having to be registered. It still needs to be declared in the project's references. If you are getting a compile error it is the latter that is the most likely cause. Open the References dialog and make sure that the vbSendMail component is checked. If it is not then this explains the error.

As I understand what you are trying to do, with an ASP interface you would expect the vbSendMail dll to be installed and registered on the webserver rather than the client and use your submit process to send the appropriate information to your dll on the webserver that then uses the sendmail one to actually send the message. Is this right or have I misunderstood?


----------



## asbo (Sep 21, 2001)

Yes, that is what I am trying to do, TimCottee, and thanks for your help.


----------



## asbo (Sep 21, 2001)

Hmm... I did as you suggested and still in the string

Private WithEvents poSendMail As vbSendMail.clsSendMail

upon running/debigging, VB highlights WithEvents and gives a

Compile Error:

Only valid in object module.

Any idea what this means??


----------



## IMM (Feb 1, 2002)

Without knowing a great deal more about what you are doing, it's tough to say, but perhaps:
Q237286 - BUG: Event Does Not Fire in the IDE When Raised from Inside a Compiled Modal Form
http://support.microsoft.com/support/kb/articles/Q237/2/86.ASP
or
http://support.microsoft.com/support/kb/articles/Q177/9/96.ASP

Have you tried it compiled?

What happens if you simply remove WithEvents from it?


----------



## TimCottee (Oct 10, 2001)

An object module is either a "class module", "form", "usercontrol" etc, a standard module is not by definition an object module and therefore you cannot use WithEvents within it. In order to do this you would be better off creating a simple class module and using this.


----------



## asbo (Sep 21, 2001)

Ok, following TimCottee's suggestion, I added a Class Module and removed the normal module. Now when I run it, in the string

Set poSendMail = New clsSendMail

the debugger highlights Set and claims:

Compile Error:

Invalid outside procedure.



Just so that everyone will know, I am about to install SP5 for VB 6.0 and see if that helps anything.


Thanks for all your help.


----------



## asbo (Sep 21, 2001)

SP5 didn't make any difference.


----------



## asbo (Sep 21, 2001)

Can anyone help?


----------



## briankm (Jun 12, 2002)

asbo,

Post or e-mail me the code and I will have a look.....

Brian
========
[email protected]


----------



## asbo (Sep 21, 2001)

Do you want the entire project or just for Command1?


----------



## briankm (Jun 12, 2002)

asbo,

I have sent a small VB project --let me know how it works for you...

Brian


----------



## asbo (Sep 21, 2001)

Will do.

Thanks much.


----------



## asbo (Sep 21, 2001)

Ok brian, couple problems right off the bat... You do know that this is an interface to be embedded in a webpage, right? Second, when I click on The Big Button, I get an "Error: ActiveX component cannot create object (429)" I suspect this has to do with the fact that that I'm running it on my XP machine, which is currently the only one with an Internet connection. I'll check it out once I get my other problem sovled.

I don't mean to sound ungrateful or anything, but that's me...


----------



## briankm (Jun 12, 2002)

asbo,

Cannot create object is typically because a .dll is not registered (i.e. use regsvr32.exe to register)....when you debug the test app which line throughs the error? If it is the one with the "new" in it then try un-registering and then re-resistering the vbsendmail.dll. If it is the "connect" then the dll may not like the XP winsock (works fine on W2K), in which case I'd suggest using the API instead of the dll.

In any event, regardless of whether or not you want it to work as part of a larger ActiveX object you are writing or not, I suggest you try to get the test app to run first. By the way, I have written several such pieces and whenever you run into problems the key is always to isolate and debug....

Also, silly question, but have you tried using the vbsendmail.dll directly from a webpage --perhaps using FP2000 or Visual InterDev instead? It is fully capable of being called from a webpage already.....

Brian


----------



## asbo (Sep 21, 2001)

briankm,



> Cannot create object is typically because a .dll is not registered (i.e. use regsvr32.exe to register)


Yes, that's what I figured. 


> ....when you debug the test app which line throughs the error?


If you mean in your app, I haven't actually run it thru VB, so the error is what I said. If you mean MY proj, then it comes from the 2nd line in Class1, highlighting Set.


> If it is the one with the "new" in it then try un-registering and then re-resistering the vbsendmail.dll.


OK, I'll poke around.


> If it is the "connect" then the dll may not like the XP winsock (works fine on W2K), in which case I'd suggest using the API instead of the dll.


API? ... How would I do that?(Please convert to newbie talk) 



> In any event, regardless of whether or not you want it to work as part of a larger ActiveX object you are writing or not, I suggest you try to get the test app to run first. By the way, I have written several such pieces and whenever you run into problems the key is always to isolate and debug....


Man I hate those words...  I'll give it a shot.



> Also, silly question, but have you tried using the vbsendmail.dll directly from a webpage --perhaps using FP2000 or Visual InterDev instead? It is fully capable of being called from a webpage already.....


Actually, I don't have either of those... I haven't poed around in MS Word much though, which could be a fine alternative, only problem being Word adds a whole bunch of junk to the script... And I was hoping I could do it by myself without having to employ another app.


----------



## briankm (Jun 12, 2002)

asbo,

Here are some links that may be of assistance:

Using Mapi controls

Howto VB DLL (using CDO)

VBNet user control (Mapi controls)

vbNet - Howto mapi

MAPI API form MS (Mapivb32.bas)

Brian


----------



## asbo (Sep 21, 2001)

Thanks, I'll check those out.


----------



## asbo (Sep 21, 2001)

Yes, I am still alive, and i haven't been able to look at those links yet bryan... 

I'm currently getting the interface done, so I'm not working around a construction zone, and I'll post again when I'm ready ot butt heads wiht this problem again.

Thanks for your help so far.


----------



## asbo (Sep 21, 2001)

Hmm... I just found out I can have FORMS in an ActiveX project... I'm gonna mess wiht that a little bit.


----------

