在.NET中发送电子邮件并将其显示在已发送的电子邮件中 [英] Send email in .NET and showing it in sent emails

查看:143
本文介绍了在.NET中发送电子邮件并将其显示在已发送的电子邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要能够使用.NET4发送电子邮件(没问题).
但是,如果我使用自己的电子邮件地址和凭据发送电子邮件,则登录Outlook帐户时在发送的电子邮件中看不到它.我根本不是电子邮件方面的专家,所以我不知道为什么我看不到我使用凭据发送的电子邮件.是否有可能在不实际打开Outlook的情况下看到从.NET发送的任何邮件显示在Outlook中的已发送电子邮件中?对于其他电子邮件客户端或提供商,这是否有不同的工作方式?

这是我到目前为止的代码.一切正常,就电子邮件而言,一切正常.

Hi,
I need to be able to send an email using .NET4 (no problem).
But if I send an email using my own email address and credentials I do not see it in my sent emails when I login to my outlook account. I am not at all an expert on emailing, so I have no idea why I cannot see the email I just sent using my credentials. Is it possible to see any mails send from .NET to be shown in my sent emails in outlook without actually opening outlook? And does this work differently for other email clients or providers?

Here is the code I have so far. Nothing out of the ordinairy and it works fine as far as emailing goes.

Dim mail As New System.Net.MailMessage
mail.Subject = "Test"
mail.Body = "This is only a test mail."
mail.To.Add(New MailAddress("myself@myemail.nl", "Naerling"))
mail.Sender = New MailAddress("myself@myemail.nl", "Naerling")
mail.From = New MailAddress("myself@myemail.nl", "Naerling")

Dim smtp As New SmtpClient
smtp.Host = "smtp.myhost.nl"
smtp.UseDefaultCredentials = False
smtp.Credentials = New NetworkCredential("username", "password")

smtp.Send(mail)

推荐答案

使用C#代码自己发送邮件时,您不会涉及Outlook,因此永远不会将其复制到已发送邮件"文件夹的机会. Outlook只是一个邮件客户端(就像您的程序一样),它将实际的发送结果留给您的电子邮件提供商.您可以(可能我从未尝试过)通过Interop通过Outlook而不是直接通过MailMessage来发送它,或者您可以尝试修改Output .PST文件,但是我怀疑这样会充满问题.

抱歉-但是,如果您不告诉Outlook,那就不会知道!
When you send the mail yourself using C# code, you are not involving Outlook in any way - so it never gets the chance to copy it to the "Sent Items" folder. Outlook is just a mail client - just like your program - it leave the actual send up to your email provider. You could (probably, I''ve never tried) send it via Outlook via Interop instead of directly via MailMessage, or you could try to modify the Output .PST files but I suspect that would be fraught with problems.

Sorry - but if you don''t tell Outlook it is not going to know!


这篇关于在.NET中发送电子邮件并将其显示在已发送的电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆