Hi all
This is very frustrating. As far as I can tell my code should work.
Indeed, I have got something similar working using VBA (and the
CDO.Message object).
I get the error "The operation has timed out" so I think that it's not
connecting to the SMTP server at all. Anyone got ideas? Here's the
code:
<code>
MailMessage m = new MailMessage();
SmtpClient c = new SmtpClient();
c.DeliveryMethod = SmtpDeliveryMethod.Network;
// I've tried this with and without the domain
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential("SmtpUserName", "SmtpPassword");
c.EnableSsl = true;
c.UseDefaultCredentials = false;
c.Host = "SmtpServer";
c.Port = 465;
c.Credentials = cred;
m.To.Add(new MailAddress("so*****@mail.com");
m.From = new MailAddress("fr**@mail.com");
m.Subject = "DotNet email";
m.Body = "Hi Ben" + Environment.NewLine + "This email
was sent via code through SMTP";
c.Send(m);
</code>
I can't see anything wrong with that. If anyone wants me to post the
VBA code that does work, I will.
I'm thinking that I may have to use CDO, which I don't really want to
do.
Thanks,
Ben 4 6491
I had problems with SMTP: mine were down to the virus checker blocking port
25; this cause stray error to be reported.
"iambenb" wrote:
Hi all
This is very frustrating. As far as I can tell my code should work.
Indeed, I have got something similar working using VBA (and the
CDO.Message object).
I get the error "The operation has timed out" so I think that it's not
connecting to the SMTP server at all. Anyone got ideas? Here's the
code:
<code>
MailMessage m = new MailMessage();
SmtpClient c = new SmtpClient();
c.DeliveryMethod = SmtpDeliveryMethod.Network;
// I've tried this with and without the domain
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential("SmtpUserName", "SmtpPassword");
c.EnableSsl = true;
c.UseDefaultCredentials = false;
c.Host = "SmtpServer";
c.Port = 465;
c.Credentials = cred;
m.To.Add(new MailAddress("so*****@mail.com");
m.From = new MailAddress("fr**@mail.com");
m.Subject = "DotNet email";
m.Body = "Hi Ben" + Environment.NewLine + "This email
was sent via code through SMTP";
c.Send(m);
</code>
I can't see anything wrong with that. If anyone wants me to post the
VBA code that does work, I will.
I'm thinking that I may have to use CDO, which I don't really want to
do.
Thanks,
Ben
Thanks. I've definitely not got that problem, and in fact I can get
this working using System.Web.Mail. Microsoft tells me that I should
be using System.Net.Mail instead, but it doesn't work!!
On 23 Oct, 10:56, AA2e72E <AA2e...@discussions.microsoft.comwrote:
I had problems with SMTP: mine were down to the virus checker blocking port
25; this cause stray error to be reported.
"iambenb" wrote:
Hi all
This is very frustrating. As far as I can tell my code should work.
Indeed, I have got something similar working using VBA (and the
CDO.Message object).
I get the error "The operation has timed out" so I think that it's not
connecting to the SMTP server at all. Anyone got ideas? Here's the
code:
<code>
* * * * * * * * MailMessage m = new MailMessage();
* * * * * * * * SmtpClient c = new SmtpClient();
* * * * * * * * c.DeliveryMethod = SmtpDeliveryMethod..Network;
* * * * * * * * // I've tried this with and without thedomain
* * * * * * * * System.Net.NetworkCredential cred = new
System.Net.NetworkCredential("SmtpUserName", "SmtpPassword");
* * * * * * * * c.EnableSsl = true;
* * * * * * * * c.UseDefaultCredentials = false;
* * * * * * * * c.Host = "SmtpServer";
* * * * * * * * c.Port = 465;
* * * * * * * * c.Credentials = cred;
* * * * * * * * m.To.Add(new MailAddress("some...@mail.com");
* * * * * * * * m.From = new MailAddress("f...@mail.com");
* * * * * * * * m.Subject = "DotNet email";
* * * * * * * * m.Body = "Hi Ben" + Environment.NewLine + "This email
was sent via code through SMTP";
* * * * * * * * c.Send(m);
</code>
I can't see anything wrong with that. If anyone wants me to post the
VBA code that does work, I will.
I'm thinking that I may have to use CDO, which I don't really want to
do.
Thanks,
Ben
iambenb schrieb:
I can't see anything wrong with that.
Works for me with the same construction (other variable values, of
course, for server, username etc..)
But I did not see you supplied a "sender". If I leave that out, our
mailserver fortunately complains.
Does it work for you, if you also supply a sender to the message?
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry
Try this....which allows "tweaking" in a much easier way.
There is a note about port 465 in the downloadable zip as well.
"iambenb" <Be********@gmail.comwrote in message
news:09**********************************@m74g2000 hsh.googlegroups.com...
Hi all
This is very frustrating. As far as I can tell my code should work.
Indeed, I have got something similar working using VBA (and the
CDO.Message object).
I get the error "The operation has timed out" so I think that it's not
connecting to the SMTP server at all. Anyone got ideas? Here's the
code:
<code>
MailMessage m = new MailMessage();
SmtpClient c = new SmtpClient();
c.DeliveryMethod = SmtpDeliveryMethod.Network;
// I've tried this with and without the domain
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential("SmtpUserName", "SmtpPassword");
c.EnableSsl = true;
c.UseDefaultCredentials = false;
c.Host = "SmtpServer";
c.Port = 465;
c.Credentials = cred;
m.To.Add(new MailAddress("so*****@mail.com");
m.From = new MailAddress("fr**@mail.com");
m.Subject = "DotNet email";
m.Body = "Hi Ben" + Environment.NewLine + "This email
was sent via code through SMTP";
c.Send(m);
</code>
I can't see anything wrong with that. If anyone wants me to post the
VBA code that does work, I will.
I'm thinking that I may have to use CDO, which I don't really want to
do.
Thanks,
Ben
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sven Templin |
last post by:
Hello all,
our configuration is as following described:
- OS: Windows 2000
- Apache server 1.3
- Php 3.8
- MS outlook client 2000
_and_ no SMTP server available in the whole intranet.
|
by: joe215 |
last post by:
I want my users to send emails from a Windows app that I am developing in
Visual Basic.NET 2003. I found a good example of sending email to a SMTP
server using the SmtpMail class. However, using...
|
by: Frank |
last post by:
I think I've confused myself completely here :-)
I have used System.Web.Mail, but am not sure if this works with Exchange Server 5.5. I asked the client if they're email server supported SMTP, and...
|
by: B-Dog |
last post by:
I've built a small app that sends mail through our ISP's SMTP server but
when I try to send through my local exchange server I get CDO error. Does
webmail use SMTP or does it strictly rely on...
|
by: Eric Sheu |
last post by:
Greetings,
I have been searching the web like mad for a solution to my SMTP problem. I
am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a
web site I have created to...
|
by: armando perez |
last post by:
Hi, this is my first time here, but I was looking for something that
may help me, and still, I haven't found something to use.
I'm using a website made in .NET with C#, when I'm running my site...
|
by: Mike Owen |
last post by:
Hi,
I am using the following code to send email on a Windows 2003 Web Server:
Imports System.Net.Mail
........
Dim msgmail As New MailMessage
msgmail.To.Add(New...
|
by: Robert Dufour |
last post by:
Dim message As New MailMessage("mymail@mydomain.com", "mymail@mydomain.com",
"Test", "Test")
Dim emailClient As New SmtpClient("localhost")
emailClient.Send(message)
The IIS server is...
|
by: =?Utf-8?B?R3V5IENvaGVu?= |
last post by:
Hi all
I use:
Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text,
txtBody.Text)
Dim emailClient As New SmtpClient(txtSMTPServer.Text)
emailClient.Send(message)
And its...
|
by: happyse27 |
last post by:
Hi All,
I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |