none
I sent only a mail but i always saw double copies mail in mailbox RRS feed

  • Question

  •  var smtp = new SmtpClient
                    {
                        Host = "smtp.gmail.com",
                        Port = 587,
                        EnableSsl = true,
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials = new NetworkCredential(fromAddress.Address, password),
                        Timeout = 20000
                    };


                    using (var message = new MailMessage(fromAddress, toAddress)
                    {
                        Subject = subject,
                        Body = tStoreName + " " + "mağazası" + " " + tDeviceName + " " + "cihazında sorun tespit edilmiştir."
                    })
                    {
                        smtp.Send(message);
                    }

    I used this code for sending mail and i dont use loop or another condition. i sent just one mail but everytime i saw double copies mail in mailbox. How can fix this issue?

    Wednesday, December 4, 2019 8:31 AM

All replies

  • Instead of sending mail message to server, store it to pickup directory by changing DeliveryMethod and setting PickupDirectoryLocation in debugging to see if two messages are actually created.

    This might also be settings in your mail provider since you are using Gmail. (And maybe testing by sending to yourself?). At least forwarding and "send mail as" settings might be reason why you see duplicate message, but does it happen if you send to someone else?

    Wednesday, December 4, 2019 10:26 AM
  • Usually by comparing the mail header of duplicate mails will give you some hint.

    Pay special attention to the "X-Received" to see if these are indeed the same mail.

    If they're the same, check to see if there is CC/BCC fields making the copies. If not, then check "Received" field to see if they come from the same SMTP server to determine whether it's mail routing problem. If they come from the same server, see if it's "mail rules" or "forwarding" as suggested by MasaSam.



    Thursday, December 5, 2019 2:46 AM
    Answerer
  • Hi Burakhan Bircan, 

    Thank you for posting here.

    I use a Hotmail address to make a test on my side, and I get one email after running the code.

    As MasaSam suggested, the problem may be caused by the setting of your gmail.

    You can use another email address to test the code, and if it works well, you need to check your setting of gmail.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 5, 2019 3:02 AM
    Moderator