Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

sending information with attachment to an email address most specifacally with google

$
0
0

I want to send an email with an attached file on button click, but it is showing 'failure sending mail' even when I have connected to the internet I still can't figure out what the problem is

private void proto_Type_AI_(object sender, RoutedEventArgs e)
        {           
            try
            {
                //Smpt Client Details                    
                SmtpClient clientDetails = new SmtpClient();
                clientDetails.Port = Convert.ToInt32(port_number.Text.Trim());
                clientDetails.Host = smtp_server.Text.Trim();
                clientDetails.EnableSsl = ssl.IsChecked == true;
                clientDetails.DeliveryMethod = SmtpDeliveryMethod.Network;
                clientDetails.UseDefaultCredentials = false;
                clientDetails.Credentials = new NetworkCredential(sender_email.Text.Trim(), sender_password.Password.Trim());

                //message details
                MailMessage maildetails = new MailMessage();
                maildetails.From = new MailAddress(sender_email.Text.Trim());
                maildetails.To.Add(recipent_email.Text.Trim());
                //maildetails.Bcc.Add("bcc email address");
                maildetails.Subject = subject.Text.Trim();
                maildetails.IsBodyHtml = html.IsChecked == true;
                maildetails.Body = body.Text.Trim();               

                clientDetails.Send(maildetails);

                MessageBox.Show("HEY USER, YOUR MESSAGE HAS BEEN SENT");

            }
            catch (Exception ex)
            {[![enter image description here][1]][1]
                MessageBox.Show(ex.Message);
            }
        }

the following is an output picture I am using google smtp to send it


Viewing all articles
Browse latest Browse all 29745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>