Hello ASP.NET programmers;

I've been searching for solutions for Mailing using Gmail not just text but also with attachments.

This code may help but I don't know what language they use to this:

/* yahoo */
public bool SendYahooMail(string sToEmail, string sFromEmail, string sHeader, string sMessage,string Password)
{
    SmtpClient client = new SmtpClient();
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.EnableSsl = true;
    client.Host = "smtp.mail.yahoo.co.in";
    client.Port = 587;
    // setup Smtp authentication
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sFromEmail, Password);
    client.UseDefaultCredentials = false;
    client.Credentials = credentials;
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
    msg.From = new MailAddress(sFromEmail);
    msg.To.Add(new MailAddress(sToEmail));
    msg.Subject = sHeader;
    msg.IsBodyHtml = true;
    msg.Body = string.Format(sMessage);
    try
    {
        client.Send(msg);
        return true;
    }
    catch (Exception ex)
    {
        return false;            
    }
}
/* Gmail*/
public bool SendGmailMail(string sToEmail, string sFromEmail, string sHeader, string sMessage,string Password)
{
    SmtpClient client = new SmtpClient();
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.EnableSsl = true;
    client.Host = "smtp.gmail.com";
    client.Port = 587;
    // setup Smtp authentication
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sFromEmail, Password);
    client.UseDefaultCredentials = false;
    client.Credentials = credentials;
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
    msg.From = new MailAddress(sFromEmail);
    msg.To.Add(new MailAddress(sToEmail));
    msg.Subject = sHeader;
    msg.IsBodyHtml = true;
    msg.Body = string.Format(sMessage);
    try
    {
        client.Send(msg);
        return true;
    }
    catch (Exception ex)
    {
        return false;            
    }
}
//

Please guide me using ASP.NET and C# as they related.

and also please help me about the FTP server which is hard for me to understand (like filezilla?).

do I need free hosting for this Project?

Can this Auto Mail be done using ASP.NET and C#?

-Zelrick

The code you are showing is C#. Try to explain your problem in detail. You are asking five questions at once, without any specifics.

Hi Sir pritaeas;

I was trying to create an auto mail by google accnts, I saw some topic that can mail manually and no attachments.

I can display images in my sample program, using somee.com but now I can't I think somee is a trial version.

Can help me build ideas how to make this? using ASP.NET and C#? or It can be done by VB.NET?

What do you mean by "auto mail"?

I think somee is a trial version.

Check with somee, I don't know what kind of hosting you have.

Hi Sir pritaeas;

It is like mailing a pictures automatically to certain Gmail Accounts.

Can this be done if I use C# alone?

For example:

This folder contains 60 below images.

The whole picture inside the folder will be sent to gmail automatically.

Is it possible?

-Zelrick

Can this be done if I use C# alone?

Sure. You can use:

msg.Attachments.Add("path/to/your/image.ext");

Hello Sir pritaeas;

I just need to add

msg.Attachments.Add("path/to/your/image.ext");

to my code in C#? then can work even no GUI?

the automation can be done also?

-Zelrick

is C#. Try to explain your problem in detail. and put full code in page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.