SmtpClient class alternative?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Afshar

    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
  • =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=

    #2
    RE: SmtpClient class alternative?

    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
    try{ Life(); } catch (TooDifficultException) { throw Toys(); }



    "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
    >

    Comment

    • Afshar

      #3
      Re: SmtpClient class alternative?

      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

      Comment

      • John Vottero

        #4
        Re: SmtpClient class alternative?

        "Afshar" <afshar.mohebbi @gmail.comwrote in message
        news:2892f763-79b7-421d-8975-738c610ed8df@8g 2000hse.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?
        >>
        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.


        Comment

        • Mark Rae [MVP]

          #5
          Re: SmtpClient class alternative?

          "Afshar" <afshar.mohebbi @gmail.comwrote in message
          news:f456aac3-cf19-49ae-9619-b9c735437394@m3 g2000hsc.google groups.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


          Comment

          • Afshar

            #6
            Re: SmtpClient class alternative?

            On Sep 21, 4:05 am, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
            "Afshar" <afshar.mohe... @gmail.comwrote in message
            >
            news:f456aac3-cf19-49ae-9619-b9c735437394@m3 g2000hsc.google groups.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: afshar.mohebbi@ 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: <ece.tester@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 ece.tester@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
            ece.tester@gmai l.com designates 74.125.78.26 as permitted sender)
            smtp.mail=ece.t ester@gmail.com ; dkim=pass (test mode)
            header.i=@gmail .com

            Received: by ey-out-2122.google.com with SMTP id 25so68580eya.49
            for <afshar.mohebbi @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: <ece.tester@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?= <ece.tester@gma il.com>
            to: =?utf-8?B?
            2qnYtNiq24zYsdi n2YbbjCDYrNmF2Y fZiNix24wg2KfYs 9mE2KfZhduMINin 24zYsdin2YY=?
            =
            <afshar.mohebbi @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: <48afbc1d.0ac01 00a.65c2.63d0@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 mVyc2lvbj0iMS4w MSIgLz4NCiAg

            PFNvZnR3YXJlIFN vZnR3YXJlRGV2ZW xvcGVyPSJodHRwO i8vd3d3LmZhcmFj b25lc2guY29t
            LyIgVmVyc2lvbj0 iMS4wLjAuMCIgR1 VJRD0iQTkwMzJDO EEtQjRFOS00YzA2 LThDQTItMDRE
            NDQwNTQ3RkFGIiA vPg0KICA8U2VuZG VyIE9yZ2FuaXphd Glvbj0i2LTYsdqp 2Kog2YHYsdin

            2qnZhti0IiBEZXB hcnRtZW50PSLYqt mI2LPYudmHINiv2 YfZhtiv2YciIFBv c2l0aW9uPSLY
            qtmI2LPYudmHINi v2YfZhtiv2YciIE 5hbWU9Itin2YHYt Nin2LEg2YXYrdio 24wiIENvZGU9
            IjU0NDMiIC8+DQo gIDxSZWNlaXZlci BPcmdhbml6YXRpb 249Itqp2LTYqtuM 2LHYp9mG24wg

            2KzZhdmH2YjYsdu MINin2LPZhNin2Y XbjCDYp9uM2LHYp 9mGIiBEZXBhcnRt ZW50PSLZvti0
            2KrbjNio2KfZhiI gUG9zaXRpb249It m
            +2LTYqtuM2KjYp9 mGIiBOYW1lPSLbj NmI2LPZgSDZ
            hdix2KfYr9uMIiB Db2RlPSI0NDQ1Ii BSZWNlaXZlVHlwZ T0iT3JpZ2luIiAv Pg0KICA8T3Ro

            ZXJSZWNlaXZlcnM gLz4NCiAgPExldH Rlck5vPjE4ODA8L 0xldHRlck5vPg0K ICA8TGV0dGVy
            RGF0ZVRpbWUgU2h vd0FzPSJqYWxhbG kiPjIwMDgtMDgtM ThUMDA6MDA6MDA8 L0xldHRlckRh
            dGVUaW1lPg0KICA 8UmVsYXRlZExldH RlcnMgLz4NCiAgP FN1YmplY3Q+2KrY s9iqINm
            +2LHZ

            iNiq2qnZhCBFQ0U 8L1N1YmplY3Q
            +DQogIDxQcmlvcm l0eSBDb2RlPSIwI iBOYW1lPSJOb3Jt
            YWwiIC8+DQogIDx DbGFzc2lmaWNhdG lvbiBDb2RlPSIwI iBOYW1lPSJOb3Jt YWwiIC8+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

            Comment

            • Mark Rae [MVP]

              #7
              Re: SmtpClient class alternative?

              "Afshar" <afshar.mohebbi @gmail.comwrote in message
              news:e1091a6d-81c8-4bf5-91d0-2eb62134ec9f@a1 g2000hsb.google groups.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


              Comment

              • Afshar

                #8
                Re: SmtpClient class alternative?

                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

                Comment

                Working...