473,657 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SmtpClient class alternative?

Dear Friends,

I want to send email but don't wanna use SmtpClient class, because I
want more control on generated mail. Is there any good alternative?
Thanks In Advance
Sep 18 '08 #1
7 5794
What kind of control are you talking about. If you want ultimate control, the
SMTP protocal is a fairly simple text based protocal so it wouldnt take long
to write your own.

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Afshar" wrote:
Dear Friends,

I want to send email but don't wanna use SmtpClient class, because I
want more control on generated mail. Is there any good alternative?
Thanks In Advance
Sep 18 '08 #2
On Sep 18, 5:34*pm, Ciaran O''Donnell
<CiaranODonn... @discussions.mi crosoft.comwrot e:
What kind of control are you talking about. If you want ultimate control,the
SMTP protocal is a fairly simple text based protocal so it wouldnt take long
to write your own.

--
Ciaran O''Donnellhttp://wannabedevelope r.spaces.live.c om

"Afshar" wrote:
Dear Friends,
I want to send email but don't wanna use SmtpClient class, because I
want more control on generated mail. Is there any good alternative?
Thanks In Advance
Thanks for reply, but I'm not very familiar with SMTP protocal and
specially its underlying TCP/IP. In fact I didn't leverage any
protocol like this. By "Full Control" I mean: I can select how email
source is generated and I could reduce the size of generated mail.

Afshar
Sep 20 '08 #3
"Afshar" <af************ @gmail.comwrote in message
news:28******** *************** ***********@8g2 000hse.googlegr oups.com...
>>
I want to send email but don't wanna use SmtpClient class, because I
want more control on generated mail. Is there any good alternative?
Thanks In Advance

Thanks for reply, but I'm not very familiar with SMTP protocal and
specially its underlying TCP/IP. In fact I didn't leverage any
protocol like this. By "Full Control" I mean: I can select how email
source is generated and I could reduce the size of generated mail.
What's wrong with SmtpClient? You can call the Send() overload that takes a
string as the message body, you have total control over how you generate
that string.
Sep 20 '08 #4
"Afshar" <af************ @gmail.comwrote in message
news:f4******** *************** ***********@m3g 2000hsc.googleg roups.com...
I want to send email but don't wanna use SmtpClient class, because I
want more control on generated mail. Is there any good alternative?
Slightly puzzled... What aspect(s) of sending email via the SmtpClient class
do not provide enough control for you...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 21 '08 #5
On Sep 21, 4:05*am, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
"Afshar" <afshar.mohe... @gmail.comwrote in message

news:f4******** *************** ***********@m3g 2000hsc.googleg roups.com...
I want to send email but don't wanna useSmtpClientcl ass, because I
want more control on generated mail. Is there any goodalternative ?

Slightly puzzled... What aspect(s) of sending email via theSmtpClientcl ass
do not provide enough control for you...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Thanks for attention, I'm developing some prtotocol called ECE over e-
mail. ECE has been invented to relate so many companies/organizations
via their ERP software. Each software developer is supposed to
implement ECE in its software. One of software developers that we had
to communicate with parses just 18 first lines of each email. Since in
the ECE protocol a header named "X-ECE_SEND" must be inserted in the
email and our generated email contains this header after line 18, so
they can not recognize our email as a valid ECE email. And I had to
find some way to insert this header in the first 18 lines of email. I
know the problem may be in MailMessage class but I guess SmtpClient
may be involved too. Here is my code for generating and sending mail
and a typical mail message produced:

------------------------------------------------------------------------------------------------------------------------------------------------------------
Generating mail itself:
public static MailMessage CreateMail(stri ng
attachmentFileN ame, string letterSubject, List<MailAddres sreceivers,
MailAddress sender, string body)
{
System.Net.Mail .MailMessage mail = new
System.Net.Mail .MailMessage();
if (!string.IsNull OrEmpty(attachm entFileName))
{
Attachment attachment = new
Attachment(atta chmentFileName) ;
mail.Attachment s.Add(attachmen t);
}
NameValueCollec tion headers = new NameValueCollec tion();
mail.Body = body;
mail.From = sender;
foreach (MailAddress addr in receivers) mail.To.Add(add r);
mail.BodyEncodi ng = Encoding.UTF8;
mail.DeliveryNo tificationOptio ns =
DeliveryNotific ationOptions.On Success;
mail.Headers.Ad d("X-ECE_SEND", "1.01");
mail.Subject = letterSubject;
return mail;
}
------------------------------------------------------------------------------------------------------------------------------------------------------------
Sending it:

public static void SendMail(MailMe ssage mail, bool enableSsl)
{
SmtpClient client = new SmtpClient();
client.EnableSs l = enableSsl;
client.Send(mai l);
client = null;
}

------------------------------------------------------------------------------------------------------------------------------------------------------------
A typical generated email:

Delivered-To: af************@ gmail.com
Received: by 10.103.12.5 with SMTP id p5cs383851mui;
Sat, 23 Aug 2008 00:28:32 -0700 (PDT)

Received: by 10.210.65.17 with SMTP id n17mr2831948eba .
92.121947651247 0;
Sat, 23 Aug 2008 00:28:32 -0700 (PDT)
Return-Path: <ec********@gma il.com>

Received: from ey-out-2122.google.com (ey-out-2122.google.com
[74.125.78.26])
by mx.google.com with ESMTP id 7si2421867eyb.
1.2008.08.23.00 .28.31;

Sat, 23 Aug 2008 00:28:32 -0700 (PDT)
Received-SPF: pass (google.com: domain of ec********@gmai l.com
designates 74.125.78.26 as permitted sender) client-ip=74.125.78.26 ;

Authentication-Results: mx.google.com; spf=pass (google.com: domain of
ec********@gmai l.com designates 74.125.78.26 as permitted sender)
smtp.mail=ec*** *****@gmail.com ; dkim=pass (test mode)
he*******@gmail .com

Received: by ey-out-2122.google.com with SMTP id 25so68580eya.49
for <af************ @gmail.com>; Sat, 23 Aug 2008 00:28:31 -0700
(PDT)

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:recei ved:received:x-ece_send:mime-
version:from
:to:subject:con tent-type:date:messa ge-id;

bh=3cBPNRMwyp8S EDcCgowEBIREX5A lIk4sOjUZjQdGm1 A=;
b=OOY7H1UVJaBX5 5dEBEzbDUmncmJz dUu66F
+Gl8Mw6ZZhMskvA LbwcAIrRuF9psMM ka

fI1CpvJcxQcvfrD OaklZPkiqPZ1P0+ LqgEncXhZOXrv9G UJVBw9HUSkEXXdY EW1wcbB/

Qub/TL+qp5HsDeU8m+b Jsm4pdgLm6AMFWR cws=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=x-ece_send:mime-version:from:to :subject:conten t-type:date

:message-id;
b=FM1ToaPqdjn8t k+/OovQX1BM91EYJNm RLu6bz98OdgC/T9NxKBeUrp1C/
jdzQeUDIm
AGgGJ20y18ko7MD rUYCwEyvjIDyl+U HGDkWvG0oI
+grdvGnMD09Tbu8 HhQU1onGLx0UR
0EYC0eYsP4wuVzY nmSf0x5drwIG/N0ZGe347g=

Received: by 10.210.125.7 with SMTP id x7mr2792181ebc.
184.12194765103 85;
Sat, 23 Aug 2008 00:28:30 -0700 (PDT)
Return-Path: <ec********@gma il.com>

Received: from programmer07 ( [91.184.73.21])
by mx.google.com with ESMTPS id p10sm9113630gvf .
7.2008.08.23.00 .28.26
(version=TLSv1/SSLv3 cipher=RC4-MD5);

Sat, 23 Aug 2008 00:28:29 -0700 (PDT)
x-ece_send: 1.01
mime-version: 1.0
from: =?utf-8?B?2LTYsdqp2Ko g2YHYsdin2qnZht i0?= <ec********@gma il.com>
to: =?utf-8?B?
2qnYtNiq24zYsdi n2YbbjCDYrNmF2Y fZiNix24wg2KfYs 9mE2KfZhduMINin 24zYsdin2YY=?
=
<af************ @gmail.com>

subject: =?utf-8?B?2KrYs9iqINm +2LHZiNiq2qnZhC BFQ0U=?=
content-type: multipart/mixed;
boundary=--boundary_1_4717 76fe-8fd3-46ee-9de3-30498d59dd48
Date: Sat, 23 Aug 2008 00:28:29 -0700 (PDT)
Message-ID: <48************ *************@m x.google.com>

----boundary_1_4717 76fe-8fd3-46ee-9de3-30498d59dd48
content-type: text/plain; charset=utf-8
content-transfer-encoding: base64

PExldHRlcj48UHJ vdG9jb2wgTmFtZT 0iRUNFIiBWZXJza W9uPSIxLjAxIiAv PjxTb2Z0d2Fy

ZSBTb2Z0d2FyZUR ldmVsb3Blcj0iaH R0cDovL3d3dy5mY XJhY29uZXNoLmNv bS8iIFZlcnNp
b249IjEuMC4wLjA iIEdVSUQ9IkE5MD MyQzhBLUI0RTktN GMwNi04Q0EyLTA0 RDQ0MDU0N0ZB
RiIgLz48U2VuZGV yIE9yZ2FuaXphdG lvbj0i2LTYsdqp2 Kog2YHYsdin2qnZ hti0IiBEZXBh

cnRtZW50PSLYqtm I2LPYudmHINiv2Y fZhtiv2YciIFBvc 2l0aW9uPSLYqtmI 2LPYudmHINiv
2YfZhtiv2YciIE5 hbWU9Itin2YHYtN in2LEg2YXYrdio2 4wiIENvZGU9IjU0 NDMiIC8+PFJl
Y2VpdmVyIE9yZ2F uaXphdGlvbj0i2q nYtNiq24zYsdin2 YbbjCDYrNmF2YfZ iNix24wg2KfY

s9mE2KfZhduMINi n24zYsdin2YYiIE RlcGFydG1lbnQ9I tm
+2LTYqtuM2KjYp9 mGIiBQb3Np
dGlvbj0i2b7YtNi q24zYqNin2YYiIE 5hbWU9ItuM2YjYs 9mBINmF2LHYp9iv 24wiIENvZGU9
IjQ0NDUiIFJlY2V pdmVUeXBlPSJPcm lnaW4iIC8+PE90a GVyUmVjZWl2ZXJz IC8+PExldHRl

ck5vPjE4ODA8L0x ldHRlck5vPjxMZX R0ZXJEYXRlVGltZ SBTaG93QXM9Imph bGFsaSI
+MjAw
OC0wOC0xOFQwMDo wMDowMDwvTGV0dG VyRGF0ZVRpbWU
+PFJlbGF0ZWRMZX R0ZXJzIC8+PFN1
YmplY3Q+2KrYs9i qINm+2LHZiNiq2q nZhCBFQ0U8L1N1Y mplY3Q
+PFByaW9yaXR5IE NvZGU9

IjAiIE5hbWU9Ik5 vcm1hbCIgLz48Q2 xhc3NpZmljYXRpb 24gQ29kZT0iMCIg TmFtZT0iTm9y
bWFsIiAvPjxLZXl 3b3Jkcz48S2V5d2 9yZD7Yqtiz2Ko8L 0tleXdvcmQ+PEtl eXdvcmQ
+2b7Y
sdmI2KraqdmEPC9 LZXl3b3JkPjxLZX l3b3JkPmVjZTwvS 2V5d29yZD48L0tl eXdvcmRzPjxP

cmlnaW5zIC8+PEF 0dGFjaG1lbnRzIC 8+PC9MZXR0ZXI+
----boundary_1_4717 76fe-8fd3-46ee-9de3-30498d59dd48
content-type: application/octet-stream; name=SendXml_62 97.xml
content-transfer-encoding: base64

PExldHRlcj4NCiA gPFByb3RvY29sIE 5hbWU9IkVDRSIgV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wiIC8+DQog
IDxLZXl3b3Jkcz4 NCiAgICA8S2V5d2 9yZD7Yqtiz2Ko8L 0tleXdvcmQ
+DQogICAgPEtleX dv

cmQ
+2b7YsdmI2Kraqd mEPC9LZXl3b3JkP g0KICAgIDxLZXl3 b3JkPmVjZTwvS2V 5d29yZD4N
CiAgPC9LZXl3b3J kcz4NCiAgPE9yaW dpbnMgLz4NCiAgP EF0dGFjaG1lbnRz IC8+DQo8L0xl
dHRlcj4=
----boundary_1_4717 76fe-8fd3-46ee-9de3-30498d59dd48--
------------------------------------------------------------------------------------------------------------------------------------------------------------

Afshar Mohebbi
Sep 21 '08 #6
"Afshar" <af************ @gmail.comwrote in message
news:e1******** *************** ***********@a1g 2000hsb.googleg roups.com...
>I want to send email but don't wanna useSmtpClientcl ass, because I
want more control on generated mail. Is there any goodalternative ?

Slightly puzzled... What aspect(s) of sending email via theSmtpClientcl ass
do not provide enough control for you...?

One of software developers that we had to communicate with parses just
18 first lines of each email. Since in the ECE protocol a header named
"X-ECE_SEND" must be inserted in the email and our generated email
contains this header after line 18, so they can not recognize our email as
a valid ECE email.
And the software developers can't / won't fix their code for you...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 21 '08 #7
And the software developers can't / won't fix their code for you...?
No, they don't want to correct this. They are not supposed to fully
support their code unfortunately.
Thanks of all other friends for their replies.
Afshar
Sep 23 '08 #8

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

Similar topics

1
8278
by: Nick Z. | last post by:
I am trying to connect to my SMTP server using the SmtpClient class. For some reason its refusing to work. Here is the code and the error I get. ----------------------------------------------------------- The code (I changed the server, user, and pass for obvious reasons): SmtpClient client = new SmtpClient("mail.server.com"); client.Credentials = new NetworkCredential("user", "pass");
11
7707
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running the app, even the first time. The application will be required to be sending out repeated emails, about one every second or two. Must this be done asynchronously? Thank you. -Greg I get the generic error messages;
10
3002
by: David Thole | last post by:
Hey all, I'm still very new at all this, but am going through the ASP.net 2.0 unleashed book, first chapter and trying to program my own little form emailer for fun. I tried following the code for their version in the book to the best of my abiltiies, and came across issues, mostly that a type was expected when trying to compile in MS Visual Studio 2002. When my stuff wasn't working at all, I decided to try just using his code almost...
0
2400
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that when the SMTPClient attaches to the server and the server sends it greeting message, if anything other than +OK is received by the client it throws an exception and falls over.
2
17472
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 the bare minimum: System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("<my mail server IP>", 25); smtp.Send("<one of my email addresses>", "<another of my email addresses>", "Hello", "World");
6
5484
by: =?Utf-8?B?VG9yc3Rlbg==?= | last post by:
Hi, I have a problem sending mails with the SmtpClient class. It's strange - after I boot the pc and start the program I can send mails many times. After I close the program and start it again it sometimes works too, but often does not. If it does not, he will never - until the next reboot. Then the "game" starts again. I get the exception "'No connection could be made because the target machine actively refused it.". Telnet to port 25...
7
22865
by: Rob Dob | last post by:
The following code is giving me a timeout problem., no matter what I do I can't send a piece of mail using .net2.0 System.Net.Mail.SmtpClient via port 465 and using ssl, if however I try using outlook or outlook express it works fine.. System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage("myemail@mydomain.com", "testemail@mydomain.com", "subject", "message body");
1
3897
by: Steve Barnett | last post by:
I'm trying to send emails using the SmtpClient class and, while the messages get sent, I can't seem to get any status information to that effect. I've hooked in to the SendCompleted event, but it never fires. Can anyone suggest why or tell me how to find out whether the email was sent or not? The code I'm using is as follows (credentials removed to protect the guilty): using System; using System.Text;
2
3832
by: btcoder | last post by:
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException and the hosting company can't find what's wrong with it so I'm here hoping somebody can help. The hosting company tried sending email from the server and it was okay and found no restrictions that prevents my page to access the smtp server. What could cause...
0
8407
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8612
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
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 we have to send another system
2
1969
muto222
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.