Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.
VB
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)
Posted

1 solution

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!
 
Share this answer
 
Comments
Sander Rossel 12-Oct-11 12:54pm    
Not what I wanted to hear... But I won't shoot the messenger. Have my 5 and answer accepted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900