Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Send mail with attachment" from ASP.NET Page
    primarykey
    data
    text
    <p>i am getting the following error. Its will the attachment that i am trying to put that it gives the error. <strong>Could not find file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\1.jpg'.</strong></p> <pre><code> &lt;div class="nav-collapse collapse"&gt; &lt;p class="navbar-text pull-right"&gt; Logged in as &lt;asp:Label ID="lblUsername" runat="server"&gt;&lt;/asp:Label&gt; &lt;asp:LinkButton ID="lnkLogout" runat="server"&gt;Logout&lt;/asp:LinkButton&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;asp:Label ID="lblMessage" runat="server" Text=""&gt;&lt;/asp:Label&gt; &lt;div class="well"&gt; &lt;div class="control-group"&gt; &lt;asp:Label ID="Label3" runat="server" Text="To" CssClass="control-label"&gt;&lt;/asp:Label&gt; &lt;div class="controls"&gt; &lt;asp:TextBox ID="txtTo" runat="server" CssClass="span12"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;asp:Label ID="Label1" runat="server" Text="CC" CssClass="control-label"&gt;&lt;/asp:Label&gt; &lt;div class="controls"&gt; &lt;asp:TextBox ID="txtCC" runat="server" CssClass="span12"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;asp:Label ID="Label4" runat="server" Text="BCC" CssClass="control-label"&gt;&lt;/asp:Label&gt; &lt;div class="controls"&gt; &lt;asp:TextBox ID="txtBCC" runat="server" CssClass="span12"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;asp:Label ID="Label2" runat="server" Text="Subject" CssClass="control-label"&gt;&lt;/asp:Label&gt; &lt;div class="controls"&gt; &lt;asp:TextBox ID="txtSubject" runat="server" CssClass="span12"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;asp:Label ID="Label5" runat="server" Text="Add Attachment" CssClass="control-label"&gt;&lt;/asp:Label&gt; &lt;div class="controls"&gt; &lt;asp:FileUpload ID="FileUpload1" runat="server" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt; &lt;/asp:ToolkitScriptManager&gt; &lt;cc1:Editor ID="Editor1" runat="server" Height="500px" /&gt; &lt;/div&gt; &lt;div class="text-center"&gt; &lt;asp:Button ID="btnSubmit" runat="server" Text="Send" CssClass="btn btn-primary" onclick="btnSubmit_Click"/&gt; &lt;input id="Reset1" type="reset" value="Reset" class="btn" /&gt; &lt;/div&gt; </code></pre> <p></p> <p>here is my code</p> <pre><code>using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Mail; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Final_Year_Project_Allocation_System.Admin { public partial class SendMailToUsers : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { try { //send email MailMessage msg = new MailMessage(); msg.From = new MailAddress("projectallocationsystem@gmail.com", "Project Allocation System"); msg.To.Add(new MailAddress(txtTo.Text)); if (txtCC.Text != "") { msg.CC.Add(new MailAddress(txtCC.Text)); } if (txtBCC.Text != "") { msg.Bcc.Add(new MailAddress(txtBCC.Text)); } if (FileUpload1.PostedFile.ContentLength &gt; 0) { Attachment attachment = new Attachment(Path.GetFullPath(FileUpload1.PostedFile.FileName)); msg.Attachments.Add(attachment); } msg.Subject = txtSubject.Text; msg.Body = Editor1.Content; msg.IsBodyHtml = true; SmtpClient setp = new SmtpClient(); setp.Host = "smtp.gmail.com"; setp.Port = 587; setp.UseDefaultCredentials = true; setp.Credentials = new NetworkCredential("projectallocationsystem@gmail.com", "*************"); setp.EnableSsl = true; setp.Send(msg); lblMessage.Text = "Please Check your mail."; lblMessage.CssClass = "alert alert-success"; } catch (Exception err) { lblMessage.Text = "Error: " + err.Message; lblMessage.CssClass = "alert alert-error"; } } } </code></pre> <p><strong>I think the error is the upload file. cant figure it out though</strong>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload