473,480 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How useful is System.Web.Mail objects.

When I use system.web.mail namespace in most of my integration programs
and in windows application programs it doesn't work.
it normally gives an exception "Could not access 'CDO.Message' object."
or "Could not access MAPI drivers". (all these machines, outlook is not
installed and local SMTP is installed and delivery configured to relay
to the mail server. all my win32 services runs under administrator.) I
was under the impression that this namespace is a wrapper to the CDONTS
object library. Apparently it is not, it needs MAPI drives to be
installed.

Only method i know to install MAPI drivers is to install MS Outlook on
the machine and create a mail profile. Please let me know if there is
another easy method?

In utter desperation I have written a wrapper to the CDONTS object
library my self and use it at the moment or using Indy SMTP socket
client (http://www.indyproject.org/). All these machines works fine
with both methods.

Is this a common problem?

Is there an easy work around for this? I like to use framework classes
so I don't need to ship these extra dlls.

Or am I doing something stupid?

Nov 17 '05 #1
3 2079
using System;
using hp;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Collections;
namespace HPsmtp
{
public class smtp
{
ManualResetEvent wait = new ManualResetEvent(false);
public string to;
public string from;
public string body;
public string subj;
public bool servermode;
public string srv;
public string name;
public string lastserver;
public int tmeout=0;
public int amount=0;
public hpsocket sck = new hpsocket();
public string MXLookup(string dmn)
{

string nl = "\r\n";
if (dmn.IndexOf("@") > -1)
{
dmn = dmn.Substring(dmn.IndexOf("@")+1,(dmn.Length-dmn.IndexOf("@")-1));
}
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "nslookup.exe";
psi.Arguments = "-type=mx "+dmn;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = Process.Start(psi);
StreamReader stmrdr = p.StandardOutput;
string s = stmrdr.ReadToEnd();
s = s.Substring(s.IndexOf("anger")+8,s.Length-(s.IndexOf("anger")+8));
s = s.Substring(0,s.IndexOf(nl));

return s;

}

public bool conn()
{
int ret;
int done=0;
string rec="";
string[] receitps;
char[] sep;
ret=sck.connect(srv,"25");
if (ret == 1)
{
return true;
}
else
{
return false;
}
}
public bool close()
{
int ret;
ret=sck.write("quit\r\n");
ret=sck.close();
return true;
}
public bool Mail()
{

int ret;
int done=0;
string rec="";
string[] receitps;
char[] sep;

rec="";
tmeout=0;

if (to.IndexOf(";") < 1)
{
amount=1;
}
else
{
// to do for multiple email address's
//receitps = (to.Split(sep,50));
}

if(servermode == true)
{
srv = MXLookup(to.Substring(to.IndexOf("@"),to.Length-to.IndexOf("@")));
}


ret=sck.write("ehlo "+srv+"\r\n");
while(true)
{
rec=sck.readbuff();
if (rec.Length > 0)
break;
wait.WaitOne(1000,false);
tmeout++;
if (tmeout > 5)
{
return false;
}
}

if (rec.Substring(0,1) == "2")
{
rec="";
tmeout=0;
ret=sck.write("mail from: <"+from+">\r\n");
while(true)
{
rec=sck.readbuff();
if (rec.Length > 0)
break;
tmeout++;
if (tmeout > 5)
{
return false;
}
wait.WaitOne(1000,false);
}

while(done < amount)
{
if (rec.Substring(0,1) == "2")
{
rec="";
tmeout=0;
ret=sck.write("rcpt to: <"+to+">\r\n");
while(true)
{
rec=sck.readbuff();
if (rec.Length > 0)
break;

wait.WaitOne(1000,false);
tmeout++;
if (tmeout > 5)
{
return false;
}

}
}
done++;
}


if (rec.Substring(0,1) == "2")
{
rec="";
tmeout=0;
ret=sck.write("data\r\n");
while(true)
{
rec=sck.readbuff();
if (rec.Length > 0)
break;

wait.WaitOne(1000,false);
tmeout++;
if (tmeout > 5)
{
return false;
}
}
if (rec.Substring(0,1) == "3")
{
rec="";
tmeout=0;
ret=sck.write("From: "+name+" <"+from+">\r\nSubject:
"+subj+"\r\n\r\n"+body+"\r\n.\r\n");
while(true)
{
rec=sck.readbuff();
if (rec.Length > 0)
break;

wait.WaitOne(1000,false);
tmeout++;
if (tmeout > 5)
{
return false;
}
}

if (rec.Substring(0,1) != "2")
{
amount=-1;
return false;
}

}
else
{
amount=-1;
return false;
}
}
else
{
amount=-1;
return false;
}

}
else
{
amount=-1;
return false;
}
return true;
}
}
}

"Eric" wrote:
When I use system.web.mail namespace in most of my integration programs
and in windows application programs it doesn't work.
it normally gives an exception "Could not access 'CDO.Message' object."
or "Could not access MAPI drivers". (all these machines, outlook is not
installed and local SMTP is installed and delivery configured to relay
to the mail server. all my win32 services runs under administrator.) I
was under the impression that this namespace is a wrapper to the CDONTS
object library. Apparently it is not, it needs MAPI drives to be
installed.

Only method i know to install MAPI drivers is to install MS Outlook on
the machine and create a mail profile. Please let me know if there is
another easy method?

In utter desperation I have written a wrapper to the CDONTS object
library my self and use it at the moment or using Indy SMTP socket
client (http://www.indyproject.org/). All these machines works fine
with both methods.

Is this a common problem?

Is there an easy work around for this? I like to use framework classes
so I don't need to ship these extra dlls.

Or am I doing something stupid?

Nov 17 '05 #2
See http://systemwebmail.com/, specifically 1.3
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Eric" <ea********@gmail.com> escribió en el mensaje
news:11**********************@g49g2000cwa.googlegr oups.com...
When I use system.web.mail namespace in most of my integration programs
and in windows application programs it doesn't work.
it normally gives an exception "Could not access 'CDO.Message' object."
or "Could not access MAPI drivers". (all these machines, outlook is not
installed and local SMTP is installed and delivery configured to relay
to the mail server. all my win32 services runs under administrator.) I
was under the impression that this namespace is a wrapper to the CDONTS
object library. Apparently it is not, it needs MAPI drives to be
installed.

Only method i know to install MAPI drivers is to install MS Outlook on
the machine and create a mail profile. Please let me know if there is
another easy method?

In utter desperation I have written a wrapper to the CDONTS object
library my self and use it at the moment or using Indy SMTP socket
client (http://www.indyproject.org/). All these machines works fine
with both methods.

Is this a common problem?

Is there an easy work around for this? I like to use framework classes
so I don't need to ship these extra dlls.

Or am I doing something stupid?

Nov 17 '05 #3
If you have smtp, just use the SmtpMail object. Just set the
SmtpServer property and call the .Send method.. both are static items.

If you want to use CDO, I think you need either the IIS mail server or
Outlook (or OE?).

HTH, Andy

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1627
by: Nick Jacobson | last post by:
The __slots__ attribute of new-style classes can reduce memory usage when there are millions of instantiations of a class. So would a __slots__ attribute for functions/methods have a similar...
1
7058
by: JSzucs | last post by:
I wrote a little code snipet in Asp.Net to send a default message to my outlook email address. That works fine, since the SMTP virtual server default domain is same domain as my outlook mail...
2
1673
by: Daniel | last post by:
how to get the number of milliseconds between two System.DateTime objects
5
1296
by: Bryan Martin | last post by:
I have a program which has ran every night fine until last night. Now it bombs with the following errors. I have also broke this down to its simplest form for sending the mail...
11
1938
by: codebloatation | last post by:
I know how to use references but i DO not get WHY they exist other than to add to the language. Are they actually needed for anything?
2
3880
by: Husam | last post by:
Hi EveryBody: I made windows application project as e-mail sender. This project consist of 13 textbox and one label and one button. I add {system.web.dll} as refrance to this project to help me...
2
1387
by: JackBlack | last post by:
Using VS.Net 2k3, 2.0 Framework installed... So, I'm sitting here trying to do a very basic SMTP mailer, and I'm struggling with getting either System.Web.Mail (1.1) to work, or System.Net.Mail...
1
5736
by: vighnesh | last post by:
Hi All Can anyone please let me know how to catch an unhandled exception like " An Unhandled exception of type 'system.stackoverflowexception' occured in mscorlib.dll " I am unable to catch...
2
17448
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7088
jinu1996
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...
1
6741
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...
0
6956
tracyyun
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...
0
5342
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4783
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.