Microsoft KB Archive/922777

= You receive an error message when you try to send an e-mail message by using the System.Web.Mail namespace in the .NET Framework 1.0 =

Article ID: 922777

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft .NET Framework 1.0

-





SYMPTOMS
When you try to send an e-mail message by using the System.Web.Mail namespace in the Microsoft .NET Framework 1.0, you receive the following error message:

0x80040220 - The 'SendUsing' configuration value is invalid

This issue occurs after you try to use the String.Insert method to change the SmtpMail.SmtpServer property. For example, the issue occurs when you try to send an e-mail message after you use code that resembles the following: SmtpMail.SmtpServer.Insert(0, &quot;mail.mycompany.com&quot;);



CAUSE
This issue occurs because the String.Insert method does not change the value of the SmtpMail.SmtpServer property. Therefore, the value of the SmtpMail.SmtpServer property is null.

Note If you try to send an e-mail message by using the System.Web.Mail namespace on the same computer that is running the Simple Mail Transfer Protocol (SMTP) server, you may not receive the error message because the e-mail message is sent to the pickup directory of the local SMTP server.



RESOLUTION
To resolve this issue, you must specifically assign the value of the SMTP server that you are using to send the e-mail message. Assign the value to the SmtpMail.SmtpServer property directly. For example, use code that resembles the following: SmtpMail.SmtpServer = &quot;mail.mycompany.com&quot;;



MORE INFORMATION
For more information about how to send e-mail programmatically by using the System.Web.Mail namespace, click the following article numbers to view the articles in the Microsoft Knowledge Base:

314201 How to send e-mail programmatically with System.Web.Mail and Visual Basic .NET

310273 How to send e-mail programmatically by using System.Web.Mail in Visual C# 2005 or in Visual C# .NET

Note Some third-party Internet Web sites have incorrect information about how to use the String.Insert method with the SmtpMail.SmtpServer property. For information about the correct usage, see the Microsoft .NET Framework documentation.

For more information about how to use the System.Web.Mail namespace and the SmtpMail class to send e-mail messages, visit the following Microsoft Web sites:

http://msdn2.microsoft.com/en-us/library/system.web.mail.smtpmail.smtpserver.aspx

http://msdn2.microsoft.com/en-us/library/system.web.mail.smtpmail_properties.aspx

http://msdn2.microsoft.com/en-us/library/system.string.insert(vs.71).aspx

http://blogs.msdn.com/mstehle/archive/2005/11/23/496418.aspx

Keywords: kbtshoot kbnofix kbprb KB922777

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.