attachemnt file at gmail not working

Posted on 2011-04-24
Last Modified: 2012-05-11
look at code plaeae what is the error
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using System.Net;

public partial class send2 : System.Web.UI.Page

    protected void Button1_Click(object sender, EventArgs e)
        string file = Server.MapPath("xml/Xml_student2011.xml");
        sendmail1("", "", "subject", "body", file);
    public static bool sendmail1(string sender, string recipient, string subject, string body, string file)
        //Create Mail Message Object with content that you want to send with mail.
        MailMessage myMailMessage = new MailMessage();

        myMailMessage.From = new MailAddress(sender);
        myMailMessage.Subject = subject;
        myMailMessage.Body = body;
        Attachment myAttachment = new Attachment(file);
        NetworkCredential mailAuthentication = new NetworkCredential("", "xxxxx");
        SmtpClient mailClient = new SmtpClient("");

        //Enable SSL
        mailClient.EnableSsl = true;
        mailClient.Port = 587;
        mailClient.Credentials = mailAuthentication;
            return true;
        catch (Exception ex)
            string ex2 = ex.ToString();
            return false;

Open in new window

Question by:myaspnet
    LVL 1

    Author Comment

    this is error
    LVL 4

    Accepted Solution

    There is a syntax error at "mail
                mailClient.Send(MyMailMessage);            return true;

    If it is just typo mistake here then have a look here
    LVL 1

    Author Closing Comment

    very good

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now