Solved

send email with out smtp server?

Posted on 2006-10-19
20
317 Views
Last Modified: 2011-10-03
hi,

1. if we have just an internet connection and no smtp server is it possible to send e-mail? if yes how?

2. if not, then can we send e-mail if we have an account in say 'hotmail' or 'yahoo mail' or 'gmail'?
0
Comment
Question by:expertfan
  • 10
  • 10
20 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 17778096
0
 
LVL 27

Expert Comment

by:Ark
ID: 17778138
0
 

Author Comment

by:expertfan
ID: 17783806
friends, i need vb6 code to achieve this. thanks.
0
 
LVL 27

Expert Comment

by:Ark
ID: 17785365
Directly from above link:
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
     
'This section provides the configuration information for the remote SMTP server.
     
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com" 'Change to your user name account at remote SMTP server, i.e. expertfan@hotmail.com
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 'Change to your password at remote SMTP server
     
ObjSendMail.Configuration.Fields.Update
     
'End remote SMTP server configuration section==
     
ObjSendMail.To = "someone@someone.net" 'recepient address
ObjSendMail.Subject = "this is the subject"   'Subject
ObjSendMail.From = "someone@someone.net" 'your address
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body" 'you can use HTML tags here, i.e. "<b>Hello world</b>"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send
     
Set ObjSendMail = Nothing
0
 
LVL 27

Expert Comment

by:Ark
ID: 17785369
PS
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com" 'change to your remote SMTP server address, i.e. "mail.hotmail.com"
0
 

Author Comment

by:expertfan
ID: 17786457
Ark,

what are these

http://schemas.microsoft.com/cdo/configuration/sendusing

these URLs are not opening i even tried http://schemas.microsoft.com/cdo/configuration
and http://schemas.microsoft.com/cdo

none of these URLs open, so whats their purpose?
0
 
LVL 27

Expert Comment

by:Ark
ID: 17786482
Those URLs aren't public domains - they are special addresses where CDO mail object check properties settings. Just copy/paste this sample "AS-IS", change:

1. "mail.yoursite.com" - to gmail/hotmail or whatever mail SMTP server address
2. "someone@someone.net" - to recepient address
3. "someone@someone.net" - to your address

If remote SMTP server (gmail, yahoo, hotmail) require authorization with login/password - uncomment following piece of code:

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com" 'Change to your user name account at remote SMTP server, i.e. expertfan@hotmail.com
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 'Change to your password at remote SMTP server
 
0
 

Author Comment

by:expertfan
ID: 17786531
hey,

i got the following error.

run-time error '-2147220973' (80040213)
The transport failed to connect to the server
0
 
LVL 27

Expert Comment

by:Ark
ID: 17786876
Did you set all properties according SMTP server requirements?
For example, smtp.gmail.com use port 465 or 587 and require SSL. Here is gmail; sample:

Private Sub Command1_Click()
   Dim ObjSendMail
   Set ObjSendMail = CreateObject("CDO.Message")
     
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True  'Use SSL for the connection (True or False)
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  'basic (clear-text) authentication
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "expertfan@gmail.com"
   ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your_password_at_gmail"
     
   ObjSendMail.Configuration.Fields.Update
     
   ObjSendMail.To = "someone@someone.net" 'recepient address
   ObjSendMail.Subject = "this is the subject"   'Subject
   ObjSendMail.from = "someone@someone.net" 'your address
     
   ObjSendMail.TextBody = "this is the body"
     
   ObjSendMail.Send
     
   Set ObjSendMail = Nothing

End Sub

0
 

Author Comment

by:expertfan
ID: 17787138
even with this code, i am getting the same error. i too used gmail id itself.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:expertfan
ID: 17787141
i am connected to internet via proxy server does this make a differnce?
0
 
LVL 27

Expert Comment

by:Ark
ID: 17787169
Some proxies doesn't allow identifictaions from local IPs - they replace it with their own. Can you connect with remote SMTP with any e-mail clients (Outlook Express, The Bat!, Eudora etc.)?
0
 

Author Comment

by:expertfan
ID: 17787178
i have only 'microsoft outlook' client, how can check out this ?
0
 
LVL 27

Expert Comment

by:Ark
ID: 17787199
Which connection does your MSOutlook use? Exchange/Pop3 etc?
Actually, you can use MSOutlook object to send e-mail using MSOutlook settings
0
 

Author Comment

by:expertfan
ID: 17787206
i use 'exchange server'.

but my application should work on machine which will be on internet (might or might not be behind firewall) but it should send out the mail with the client on that PC.
0
 

Author Comment

by:expertfan
ID: 17789113
hi ark,

your code is working fine when there is no firewall.


but doesn't work when behind firewall....please advise.
0
 
LVL 27

Expert Comment

by:Ark
ID: 17792077
Just add your application to the firewall exception list.

You can also try direct winsock e-mailer (http://www.vbforums.com/showthread.php?t=334745), but I'm sure firewal block it too
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 17792089
PS - try also another smtp servers which use default smtp 25 port - all firewalls usualy don't block this port by default, but anyway all depends on local firewall settings
0
 

Author Comment

by:expertfan
ID: 17793502
>>>try also another smtp servers which use default smtp 25 port

hi ark, do u know any example of hotmail or yahoo which works on 25 port?
0
 

Author Comment

by:expertfan
ID: 17878669
thanks Ark, i hope some one can get this working for 'behind the firewall' too...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now