how to use external smtp to send email using vb6 exe prog?

You can talk about VB programming here

how to use external smtp to send email using vb6 exe prog?

Postby method » Thu Apr 06, 2006 9:18 pm


Hi all. i am new to vba. i be happy if some one send me the code on how to use external smtp to send email using a vb6 .exe program.Thanks
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Thu Apr 06, 2006 11:46 pm

well i use vbnet and vbscript to send email by using gmail smtp
I'm vbnet and c# programmer but not really in vb but here it's the code to send mail with vbscript using gmail.
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="xxxx@gmail.com"
myMail.TextBody="This is a message."
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")="youraccount@gmail.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")="yourpassword"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=465
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl")=true
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com"
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
Last edited by BattleStar-Galactica on Thu Apr 13, 2006 3:15 pm, edited 1 time in total.
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby BattleStar-Galactica » Fri Apr 07, 2006 12:39 am

I do the test for vb, it's ok too, this code works for vb too, hope it can be useful for you method
enjoy coding and coding for fun :lol:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby method » Fri Apr 07, 2006 3:46 pm

nanomachine007 wrote:I do the test for vb, it's ok too, this code works for vb too, hope it can be useful for you method
enjoy coding and coding for fun :lol:


Many thanks for both of u. nanomachine007 could u tell me how i can use this code in visual studio version 6? I am new to vb so i be happy if u tell me the steps to use this code and make .exe file and one a click of a button it sends the email and shows a confirmation massge.Thanks
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Fri Apr 07, 2006 4:47 pm

to use the code i posted you have to create a gmail account and copy that code to your sub button click and replace youraccount@gmail.com by your gmail account and your password by your real gmail account password.
to create the file .exe go to microsoft visual studio 6.0 tool, click on package&deployment wizar, it will tell you the next step to make your exe file.
and for the confirm message in vb6 they have the statement to intercept the error >>> On Error goto and On Error Resume next, you can use
On Error goto 1
code to send mail here
message send mail success
exit sub
1:
message error here
me too i'm not really good in vb, i just can do some basic thing :cry:
loco maybe have more info about that, hey loco show him some trick :lol:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby method » Fri Apr 07, 2006 6:38 pm

Thanks nanomachine007 i made it to work!! But now i want to know how i can send ip address and mac address of mechine with the email. Loco i hope u or any expert help me here.Thanks


myMail.TextBody="This is a message." ====> add ip address and mac address
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Sat Apr 08, 2006 12:55 pm

to find the ip address of the machine that runs your app, it's not hard.
under your project add a winsock compoment and you can get it by calling winsock.localip, for MAC address, i dont know, i never try to get it, how is the utility to get MAC of other machine???? but I think loco know how to get maybe you have to wait he read you post :lol:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby BattleStar-Galactica » Thu Apr 13, 2006 3:14 pm

dam thing, someone try my code and send me a email, please replace my email as yours to do test. :twisted:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby method » Tue Apr 18, 2006 12:42 pm

nanomachine007 is it possible to send attachment using this code ? I be happy if u show me how.Thanks
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Tue Apr 18, 2006 8:07 pm

method wrote:nanomachine007 is it possible to send attachment using this code ? I be happy if u show me how.Thanks


yep you can do it by adding this line after your message

myMail.AddAttachment("c:\youfile.txt")
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby locohacker » Fri Apr 21, 2006 6:25 am

lol guys u hook me up sorry I dint reply sooner lol but I guess u guys figure stuff out, but let me just tell ya this code righ here is going to help me big time for a new program I am workign on :) ah only vip members will be able to get if for now lol, let me make u vip I should be finish soon on it check the vip section :)
User avatar
locohacker
Site Admin
Site Admin
 
Posts: 4363
Joined: Fri Dec 31, 2004 6:59 pm


Return to Visual Basic Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests