AshleighGreen
asked on
Delivery Notification through C# 1.1
I want to receive a delivery notification when sending an email through ASP.NET 1.1 C#.
I can get a read notification using;
testMessage.Headers.Add("d isposition -notificat ion-to", txtFrom.Text);
However I cannot get a delivery notification. I have tried;
testMessage.Headers.Add("R eturn-Rece ipt-To", txtFrom.Text);
and/or
testMessage.Fields.Add("ur n:schemas: mailheader :return-re ceipt-to", txtFrom.Text);
Neither work.
I am sending from domain 1 to domain 2. They are not linked in anyway. Manually (through outlook) sending an email with request delivery notification selected works perfectly from domain 1 to domain 2. However when I create and send the same email through a windows/ASP.NET application no delivery notification is returned.
I know this is made much simpler in .Net 2.0+. But that isn't an option with this application. Does anyone have a solution to this issue?
I can get a read notification using;
testMessage.Headers.Add("d
However I cannot get a delivery notification. I have tried;
testMessage.Headers.Add("R
and/or
testMessage.Fields.Add("ur
Neither work.
I am sending from domain 1 to domain 2. They are not linked in anyway. Manually (through outlook) sending an email with request delivery notification selected works perfectly from domain 1 to domain 2. However when I create and send the same email through a windows/ASP.NET application no delivery notification is returned.
I know this is made much simpler in .Net 2.0+. But that isn't an option with this application. Does anyone have a solution to this issue?
System.Web.Mail.MailMessage testMessage = new System.Web.Mail.MailMessage();
System.Web.Mail.SmtpMail.SmtpServer = txtSMTP.Text;
testMessage.To = txtTo.Text;
testMessage.From = txtFrom.Text;
testMessage.Subject = txtSubject.Text;
testMessage.Body = txtBody.Text;
testMessage.BodyFormat = System.Web.Mail.MailFormat.Text;
if(chkDelivery.Checked)
{//Not Working! :-(
testMessage.Headers.Add("Return-Receipt-To", txtFrom.Text);
//testMessage.Fields.Add("urn:schemas:mailheader:return-receipt-to", txtFrom.Text);
}
if(chkRead.Checked)
{
testMessage.Headers.Add("disposition-notification-to", txtFrom.Text);
}
System.Web.Mail.SmtpMail.Send(testMessage);
ASKER
Hello aibusinesssolutions,
Thanks for the quick reply. Yes, I did see a number of articles talking about the DSNOptions when sending through ASP flat. I have, as yet, been unsuccessful in finding a way to modify the DSNOption. I was also considering if it would be better to just access the CDO.Message object directly, and bypass using the System.Web.Mail wrapper, however I haven't found any good examples of how to do that either.
I'm looking forward to the results of your further digging,
-Ashleigh
Thanks for the quick reply. Yes, I did see a number of articles talking about the DSNOptions when sending through ASP flat. I have, as yet, been unsuccessful in finding a way to modify the DSNOption. I was also considering if it would be better to just access the CDO.Message object directly, and bypass using the System.Web.Mail wrapper, however I haven't found any good examples of how to do that either.
I'm looking forward to the results of your further digging,
-Ashleigh
Here is an example of using the CDO, I'm sure it can be modified to work with asp.net 1.1
http://support.microsoft.com/default.aspx?scid=kb;en-us;302839
http://support.microsoft.com/default.aspx?scid=kb;en-us;302839
ASKER
Hey,
I have seen that example for asp, however am unsure of how to convert that into c#.
I have seen that example for asp, however am unsure of how to convert that into c#.
Well, before you do that, did you check the headers of the email in your email client?
I just tried msg.Headers.Add("Return-Re ceipt-To", "xxxx@xxxx.com");
and got this, also the checkbox saying a delivery receipt was request was checked.. but I never got a delivery notification.
Return-Receipt-To: <xxxx@xxxx.com>
From: <xxxx@xxxx.com>
To: <xxxx@xxxx.com>
Date: Mon, 23 Feb 2009 19:00:26 -0500
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:messag e
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7000.0
Return-Path: xxxx@xxxx.com
X-MS-Exchange-Organization -SCL: 0
I just tried msg.Headers.Add("Return-Re
and got this, also the checkbox saying a delivery receipt was request was checked.. but I never got a delivery notification.
Return-Receipt-To: <xxxx@xxxx.com>
From: <xxxx@xxxx.com>
To: <xxxx@xxxx.com>
Date: Mon, 23 Feb 2009 19:00:26 -0500
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding:
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:messag
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7000.0
Return-Path: xxxx@xxxx.com
X-MS-Exchange-Organization
And this is what it looks like when I do it through Outlook, and I DO get a delivery receipt with this.
From: xxxxx <xxxx@xxxx.com>
To: xxxxx <xxxx@xxxx.com>
Return-Receipt-To: <xxxx@xxxx.com>
Date: Mon, 23 Feb 2009 18:09:14 -0600
Subject: test
Thread-Topic: test
Thread-Index: AcmWFCBDJO3OadtNSAO0hyaRsu 9O/w==
Message-ID: <20F36FA53D393246A84B0B2E4 20DB3876BA 5DCFC59@xx xx.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-Exchange-Organization -SCL: -1
X-MS-TNEF-Correlator: <20F36FA53D393246A84B0B2E4 20DB3876BA 5DCFC59@xx xx.com>
MIME-Version: 1.0
From: xxxxx <xxxx@xxxx.com>
To: xxxxx <xxxx@xxxx.com>
Return-Receipt-To: <xxxx@xxxx.com>
Date: Mon, 23 Feb 2009 18:09:14 -0600
Subject: test
Thread-Topic: test
Thread-Index: AcmWFCBDJO3OadtNSAO0hyaRsu
Message-ID: <20F36FA53D393246A84B0B2E4
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-Exchange-Organization
X-MS-TNEF-Correlator: <20F36FA53D393246A84B0B2E4
MIME-Version: 1.0
Well I tried adding different headers in, and it doesn't seem to work regardless, I think you're just going to have to use the CDOSYS.
ASKER
Hey,
I have checked that. I've also looked at what the headers are like in 2.0 where delivery receipt is an option. Interestingly they look like this;
MIME-Version: 1.0
From: <XXXXX@XXXX>
To: <XXXXX@XXXXXXXXXXX>
Date: Tue, 24 Feb 2009 10:08:23 +1030
Subject: Testing Delivery Receipt 2.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Return-Path: XXXXX@XXXXXX
Message-ID: <XXXZhCl8aii08N8y0000018c@ XXXXXX>
It worked, and there isn't even a Return-Receipt-To.
I have checked that. I've also looked at what the headers are like in 2.0 where delivery receipt is an option. Interestingly they look like this;
MIME-Version: 1.0
From: <XXXXX@XXXX>
To: <XXXXX@XXXXXXXXXXX>
Date: Tue, 24 Feb 2009 10:08:23 +1030
Subject: Testing Delivery Receipt 2.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding:
Return-Path: XXXXX@XXXXXX
Message-ID: <XXXZhCl8aii08N8y0000018c@
It worked, and there isn't even a Return-Receipt-To.
Here's something on using CDOSYS in C#. It's for checking mail in the drop directory, but it'll get you started.
ASKER
Yes, I am coming to that conclusion also. But I am unsure of how to use the CDOSYS in C#.
It's really weird, I got the example working in C#, but when I set the DSNOptions I never get the email.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,
This worked perfectly. It sent the message fine, and the message contained the delivery notification worked. The read notification also worked fine.
As a note to anyone else who may come across this solution. The file to reference was c:\windows\system32\cdosys .dll
Thanks heaps for your help.
This worked perfectly. It sent the message fine, and the message contained the delivery notification worked. The read notification also worked fine.
As a note to anyone else who may come across this solution. The file to reference was c:\windows\system32\cdosys
Thanks heaps for your help.
I was using SMTP authentication with that example, so that may be why it wasn't working for me. Glad I could help.
' cdoDSNDefault 0 No DSN commands are issued.
' cdoDSNNever 1 No DSN commands are issued.
' cdoDSNFailure 2 Return a DSN if delivery fails.
' cdoDSNSuccess 4 Return a DSN if delivery succeeds.
' cdoDSNDelay 8 Return a DSN if delivery is delayed.
' cdoDSNSuccessFailOrDelay 14 Return a DSN if delivery succeeds, fails, or is delayed.
I'll keep digging and see if I can find something useful.