Solved

how do I setup my webconfig for smtp?

Posted on 2008-10-19
4
2,744 Views
Last Modified: 2013-11-30
I need to setup smtp  with the below for asp.net 3.5

<system.net>
    <mailSettings>
      <!-- <smtp deliveryMethod="Network"> -->
      <smtp deliveryMethod="PickupDirectoryFromIis" from="webmaster@omegalove.com">
        <network defaultCredentials="true" host="omegalove.com)" port="25" />
      </smtp>
    </mailSettings>
  </system.net>

any help would be appreciated.
Iget the following errror:
 get the following error.
Cannot get IIS pickup directory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Cannot get IIS pickup directory.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SmtpException: Cannot get IIS pickup directory.]
System.Net.Mail.IisPickupDirectory.GetPickupDirectory() +1101325
System.Net.Mail.SmtpClient.Send(MailMessage message) +1480
System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +367
System.Web.UI.WebControls.PasswordRecovery.AttemptSendPasswordUserNameView() +537
System.Web.UI.WebControls.PasswordRecovery.AttemptSendPassword() +55
System.Web.UI.WebControls.PasswordRecovery.OnBubbleEvent(Object source, EventArgs e) +103
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565




--------------------------------------------------------------------------------
0
Comment
Question by:mathieu_cupryk
  • 2
  • 2
4 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22755103
change the following line to
    <network defaultCredentials="true" host="omegalove.com)" port="25" />

<network defaultCredentials="true" host="omegalove.com" port="25" />


one more suggestion
in the above line remove defaultCredentials and put in a valid domain user name and password and try agian
<network host="omegalove.com" port="25" userName="username" password="password"/>
0
 

Author Comment

by:mathieu_cupryk
ID: 22764694
Cannot get IIS pickup directory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Cannot get IIS pickup directory.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:
0
 

Author Comment

by:mathieu_cupryk
ID: 22764705
I got an email from the host to do the following:
i am confused:

It is mandatory to use SMTP authentication for sending out emails through our servers. You can use the below sample C# code for the same (by making required modifications):

***********************************************************************************
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();

MailAddress fromAddress = new MailAddress("from@from.com", "From Name");

// You can specify the host name or ipaddress of your server
smtpClient.Host = "mail.yoursite.com"; //you can also specify mail server IP address here

//Default port will be 25
smtpClient.Port = 25;

NetworkCredential info = new NetworkCredential("smtpuser@yoursite.com", "smtp-password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = info;

//From address will be given as a MailAddress Object
message.From = fromAddress;

// To address collection of MailAddress
message.To.Add("to@domain2.com");
message.Subject = "Your subject";

// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
//message.Bcc.Add("bcc@yoursite.com");

//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;

// Message body content
string ss_body = "body of email is here";
message.Body = ss_body;

// Send SMTP mail
smtpClient.Send(message);
***********************************************************************************
 
I though I only needed to modify my webconfig? please help.
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22764781
its not mandatory for the SMTP to use the authentication information but its dependent on the settings of the SMTP server
If you configure your SMTP server to send emails without authentication then your previous code sample will also work
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello Friends, My friends and relatives always ask me how to delete all the various types of emails at once in our g-mail  or windows live account.  So I researched this topic to find a unique solution to this query.  Here it is for those who do …
Pop culture is prime bait for hackers seeking to infect user’s computers and mobile devices with malicious malware. Hackers know exactly what the latest trends are online and know how to use them to their advantage.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now