Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send email with static library ???

Status
Not open for further replies.

jajest

IS-IT--Management
Nov 6, 2003
28
BE
hello,

I want to write a VB6 program that can send an email making use of our mailserver in the LAN. I do not want to make use of third party external dll's, DOS shell or outlook/OE.

Is there no sample out there to include all code int the program so that the result is one and only .exe file after compilation ?
 
You are asking two different questions, really.

1) Can I send email 'natively' from VB via a mailserver
2) is it possible to make a completely standalone, single EXE VB application?

Answers
1) You can leverage the fact that Windows 2000 and later ship with an SMTP-capable library, CDO. Check out my code in thread222-1143694 for an example on how to use it.
2)Not entirely, since any VB application relies on a core set of runtime libraries. However, for years now these have shipped with the OS, so as long as you don't use any other libraries that are not included with the OS, then your goal is indeed possible.
 
hi strongm

I have read the thread that you refered to and I succesfully used the code mentioned there.

However, there's one thing that holds me busy thinking.
I have some experience in sending email through mailserver from within VB but this time is the first time that I have to give a username and password ?!?

It works but I wonder why it needs username+pw. Notmally sending an email through SMTP, it is sufficient that the sending IP address belongs to the local LAN and only a username+pw are needed for POP3 ?

Is there no way to avoid using username+pw ?
 
You only need to supply user credentials if the server requires them. Otherwise you can use an anonymous session.

Not many servers will do anonymous forwarding anymore because of out of control spamming. Of course nothing keeps you from running an in-house SMTP server that does accept it though, it just isn't always easy to get from there to the global SMTP network.
 
I have an inhouse SMTP server running. This was the reason why i asked this second question. I used to use a command line utility that I launched from within VB through a dos shell. The only parameters I needed to provide was ip address of the (in-house- mailserver), from, to, subject, body, etc, etc but NOT username and password...

I'm wondering why now I have to ?
 
Does anybody actually read the code I present anymore?

I very specifically state in teh commented version:

' Don't bother with the following 3 lines of code if the SMTP server you will be connecting to
' does not require authentication

How much clearer do I need to be?
 
Huh???

I don't get it, strongm. What are you trying to say?



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I'm commenting on jajest's comments that

>It works but I wonder why it needs username+pw. Notmally sending an email through SMTP, it is sufficient that the sending IP address belongs to the local LAN and only a username+pw are needed for POP3 ?

 
@strongm

hello,

you're right ! The reason why I did not read that comment is because I was focusing on the short version that you posted also in the above mentioned link and in the short version, there's no comment. That's why. But anyway, it is working now as I wanted. Therefore thanks ! You're the man.
I don't get it why anybody would use an external dll which need to be copied with the exe if you can use this !

thank you.

Marc
 
Glad my code was of some help.

And sorry if I sounded a little grouchy above - I wrote my last 2 posts whilst somewhat (very) inebriated after attending a leaving party ...
 
no problem! what you say was very correct.

And I also don't care that this code doesn't support W95/98/ME. such machines are not used anymore in a business environment. I guess CDO support will continue to happen in future versions of windows. How about Vista for example ?
any news on that ?

Marc
 
jajest said:
I don't get it why anybody would use an external dll which need to be copied with the exe if you can use this !
For the same reason we break up our large applications into DLL's - code maintanability and reuse.

Let's say you copy and paste your email code into 50 applications. Then one day you find a way to improve the code, or you find and fix a bug. In order to apply it to all 50 applications, you must recompile and redistribute all 50. It's far easier to distribute a new DLL.

 
No, in this case I think what is being asked is if a dll already exists on all current versions of an OS, a dll that is easy to use and does exactly what you want then why would you want to use a different dll that yoiu have to ensure ships wity your app.

The question isn't about including the author's own code into a dll.

 
Ah, thanks for the clarification StrongM. My apologies to the OP.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top