**C#:**

```C#
private  void SendEmail(object sender, EventArgs e)
        {
            string subject = "subject here ";
            string body = "body here ";
                var mail = new MailMessage();
                var smtpServer = new SmtpClient("smtp.gmail.com", 587);
                mail.From = new MailAddress("veezo2007pk@gmail.com");
                mail.To.Add("veezo2009pk@gmail.com");
                mail.Subject = subject;
                mail.Body = body;
                System.Net.Mail.Attachment attachment;
                attachment = new System.Net.Mail.Attachment();
                mail.Attachments.Add(attachment);
                smtpServer.Credentials = new NetworkCredential("veezo2007pk", "password");

                smtpServer.UseDefaultCredentials = false;
                smtpServer.EnableSsl = true;
                smtpServer.Send(mail);

        }

private async void File(object sender, EventArgs e)
        {

          var file = await CrossFilePicker.Current.PickFile();                      

            if (file != null)
            {
                fileLabel.Text = filepath;
            }
        }

```

**XAML:**

```XAML
 <Entry Placeholder="Phone No" x:Name="Phone" />  
                <Button Text="Pick a file" x:Name="fileButton" Clicked="File"/>
                    <Label Text="This is FileName" x:Name="fileLabel"/>    
                <Button Text="Submit" Clicked="SendEmail" BackgroundColor="Crimson" TextColor="White" WidthRequest="100" />

```

I want to send an email with an attachment. If I remove the code for the attachment the email gets to the recipient. When I am using the code for the attachment the email is not sent. I don't know why....