You must Sign In to post a response.
  • Category: ASP.NET

    Failed to map the path '/images/fb.gif'

    My code as follows

    Attachment imgAtt1 = new Attachment(Server.MapPath("\\images\\fb.gif"));
    Attachment imgAtt2 = new Attachment(Server.MapPath("\\images\\twiter.gif"));

    imgAtt1.ContentId = "\\images\\fb.gif";
    imgAtt2.ContentId = "\\images\\twiter.gif";

    mailmess.To.Clear();
    smtpserver.Send(mailmess);
    mailmess.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
    mailmess.Dispose();

    When i run the above code shows error as follows

    Failed to map the path '/images/fb.gif'

    The above error shows in below line as follows

    Attachment imgAtt1 = new Attachment(Server.MapPath("\\images\\fb.gif"));

    please help me what is the mistake i made.
  • #764136
    Hai Rao,
    You can try it as below:

    Attachment imgAtt1 = new Attachment(Server.MapPath("~/images/fb.gif"));
    Attachment imgAtt2 = new Attachment(Server.MapPath("~/images/twiter.gif"));

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #764137
    Hi Rao.

    Refer below code snippet

    Attachment imgAtt1 = new Attachment(Server.MapPath("~\images\fb.gif"));
    Attachment imgAtt2 = new Attachment(Server.MapPath("~\images\twitter.gif"));

    imgAtt1.ContentId = "~\images\fb.gif";
    imgAtt2.ContentId = "~\images\twitter.gif";

    mailmess.To.Clear();
    smtpserver.Send(mailmess);
    mailmess.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
    mailmess.Dispose();

    Sridhar Thota.
    Editor: DNS Forum.

  • #764141
    1. You do not need to pass the escape. Simple use "/images/twiter.gif".

    2. You can try the following way.

    Attachment imgAtt1 =Path.Combine(System.Web.HttpContext.Current.Server.MapPath("."), "/images/fb.gif");

    Attachment imgAtt2 =Path.Combine(System.Web.HttpContext.Current.Server.MapPath("."), "/images/twiter.gif");

    By Nathan
    Direction is important than speed


Sign In to post your comments