mike's web log

 

Blog Search


(Supports AND)

 

Google Ads

 

Feed

Subscribe to the RSS feed for this blog.

See this post for info on full versus truncated feeds.

 

Quote

I've shaken things up with a redhead. I learned my lesson.

"Don Draper"



 

Navigation






<April 2014>
SMTWTFS
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910


 

25 Most-Visited Entries

 

Categories

  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
 

Blogs I Read

 

Contact

Email me
 

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 4/3/2014

Totals
Posts - 2298
Comments - 2480
Hits - 1,618,894

Averages
Entries/day - 0.58
Comments/entry - 1.08
Hits/day - 410

Update every 30 minutes. Last: 12:15 PM Pacific

 
   |  Extending System.Web.Mail

posted at 01:00 AM | | [9] |

A little preview: at work today, someone noted to me that in .NET 1.1, they added support for CDO fields to my good friend the System.Web.Mail class. The theory is that this will allow us to set/pass values that are not directly exposed via properties on the MailMessage class. The canonical example goes like this:
MailMessage m = new MailMessage(); 
m.From = "..."; // fill in appropriately
m.To = "..."; // fill in appropriately
m.Subject = "Subject";
m.Body= "test " + DateTime.Now.ToString();
m.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
m.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = user;
m.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password;
SmtpMail.Send(m);
And in fact, mharder had a a post about this on the forums a while back. (Who knew? Not me.)

The example illustrates the solution to a popular question: how to pass authentication credentials with an email message if the server requires logon. I got this working tonight on my local SMTP server. The smtpauthenticate field is set to 1 in the example, which per the CdoProtocolsAuthentication enum indicates Basic. So I set my SMTP server to require Basic auth, turned off anonymous access, and gave it a try. Worked!

According to the docs, you're supposed to be able to set other fields as well. The other one that really interests me is setting the Reply-To field, another question I've been asked. Alas, no luck. I'm trying this:
m.Fields("http://schemas.microsoft.com/cdo/configuration/senduserreplyemailaddress") _
= "Mike Pope <mikepope@myotherdomain.com>"
(In VB, of course.) The field and value are accepted (changing the field name to "foo" throws), and the email gets sent. However, when I grub around in the message details, there's no reply-to info anywhere. So I don't know what CDO is doing with this value that I'm setting.

Well, perhaps that will solve itself.


Update, 1:36am Well, shoot -- thanks to Colt (see comment), we also now have Reply-To figured out. Basically, we now know that the Headers property, which is a simple dictionary, will take any header value (that is, anything documented here). By golly, I've learned two things today, and it's barely past midnight.

[categories] ,