When i am sending mail through outlook in c# ,all the mails are saved in sent box. Is there any way which does not leave the copy of mail in sent folder programatically.
Set the MailItem.DeleteAfterSubmit property to true before calling Send.
Related
I looked on SO an found several ways to do kind simmilar things, but those aren't the solution.
A user is on the web page and on a click on a file (which is stored in byte[] on server) should open the mail client, where the attachment, subject and mailfrom is set.
Subject and Mail From is no problem, but the attachment. Here are some points I need/need not to:
I cannot/I am not allowed to Create a file such as mymailmessage.eml
on a client (access denied)
I cannot use MailMessage
(System.Net.Mail) because for this I need to create a file to open the mail client with Process.Start(filename)
I cannot use mailto: because there I cannot add an attachment
So the way I am on for now is to use MAPI. Unfortunately I have not found a solution. My source is a byte[] and I can write this in a MemoryStream. Is it possible to create a kind of virtual file path in C#? But I don't know how to open the mail client including the parameters. All the MAPI projects (like https://github.com/PandaWood/Simple-MAPI.NET or https://www.codeproject.com/Articles/10881/MAPIEx-Extended-MAPI-Wrapper are using local files. I tried those, but in my case the mail client isn't starting, so no mail message window is popping up.
So what I am looking for is: Create a MapiMessage with MailFrom, Subject, an attachment and then open the mail client (like with mailto) including the attachment.
An other C# project is this: https://www.codeproject.com/Articles/17561/Programmatically-adding-attachments-to-emails-in-C
According to this codeproject, I cannot find the line, where the programm is saying the mail client please open (like Process.Start()) and open the prepared mail message for me.
Is there any other way except MAPI, when I only have a byte[] in the web application and need to open a mail client message including the attachment not storing/downloading it on the user client?
I know how to send programmatically mails via shared mailbox in Outlook via Office.Interop.
But still mail Ive sent is being stored in my personal sent items folder (instead of Shared Mailbox' Sent items).
So other people cant see what was sent. Also it consumes my mailbox size quotas ...
Is there any way to send mails via Shared Mailbox and keep sent items there ?
If not (so easy) than at least copy sent mail from my sent items folder top shared mailbox ?
* EDIT *
Below is my current code:
Application app = new Application();
MailItem mailItem = app.CreateItem(OlItemType.olMailItem);
mailItem.Subject = subject;
mailItem.To = to;
mailItem.SentOnBehalfOfName = fromMail;
// Send
mailItem.Send();
You just need to set the MailItem.SaveSentMessageFolder property which sets a Folder object that represents the folder in which a copy of the email message will be saved after being sent.
Be aware, the folder should be presented in your store. If you need to move the sent items I'd recommend handling the ItemAdd event on the folder (Sent Items by default) and move items programmatically by calling the Move method.
I'm currently experiencing some strange behavior when sending e-mails using Outlook (Office 365 Pro Plus).
Our software can generate e-mails and show a new mail compose to the user with attachments which they selected from our software. (We use both Redemption from our software as Outlook Object Model using an Outlook Add-in Express add-in)
Below you can find the code for generating the e-mail using Redemption:
bool createEmail = false;
RDOSession session = new RDOSession();
session.Logon("", "", false, false, null, false);
RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderDrafts);
RDOMail mail = folder.Items.Add("IPM.Note");
... Code for selecting receivers (returns string with emailadresses) ...
... Code for converting word documents to PDF / Adding the attachments to the mailitem ...
RDOUserProperty userProp = mail.UserProperties.Add("DMS_AttachmentCount", rdoUserPropertyType.olInteger, false, false);
userProp.Value = mail.Attachments.Count;
mail.Display();
I noticed that I'm not using
mail.Save();
Could that be the issue?
When we show the user the generated e-mail all attachments are in place and the user is able to open the attachments.
So far so good...
Here comes the problem:
On sending the e-mail, sometimes (i mean really sometimes) some of the
attachments are deleted from the e-mail. When the user goes to it's
sent items and selects the e-mail, some of the attachments are
deleted.
Since this occurs randomly, I'm not able to debug this issue.
What have I tried already:
Turn off ESET Nod32 and all of it's e-mail components
Disabled Office Secured Mode
Exclude certain file extensions from being scanned.
Checked for third party add-ins, so far only the list below is installed
The rest of the add-ins are default by Outlook
My question(s):
Is there somebody out there that has experienced the same problem?
How can I determine what happens inside the Item Send event?
What else can I turn off or apply on the server that might prevent this issue from happening?
Thanks.
I want to open the default mail client registering on Windows and create an email with an attachment.
The behaviour is just like when you right click on a file, the Send to -> Mail Recipient. Or when you compressing a folder and select 'compress and email' on the context menu.
I have tried:
mailto:xxx#example.com, which doesn't accept attachment.
MAPI, which works well when the outlook is shutdown, but doesn't work when the outlook is currently working. Do you know how to make it work?
Do you have any other ideas?
Thanks!
Depending on the version of your mail client, try to add &attach="C:\some_file.txt to the end of mailto:xxx#xxx.com. This should add an attachment when the mail client opens. If attach does not work, try attachment in stead. I wonder if you can't add both.
I am trying to build a winform app to
read mails from google app
save mail and attachment to local folder
mark mail as read
Save the email body and attachments to a SQL-Server database
The latter is ok but I'm really having trouble with the first 3.
I've look everywhere and people are telling me how to send mail on a winform app but not how to read, mark and save content and attachment.
CodeProject is probably the next best resource online after SO (IMHO.) Here are some well-reviewed sample projects that will get you a long way:
http://www.codeproject.com/Articles/14304/POP3-Email-Client-NET-2-0
http://www.codeproject.com/Articles/6062/A-POP3-Client-in-C-NET
http://www.codeproject.com/Articles/188349/Read-Gmail-Inbox-Message-in-ASP-NET
http://www.codeproject.com/Articles/34495/Building-your-own-Mail-Client-using-C
http://www.codeproject.com/Articles/15611/POP3-Email-Client-with-full-MIME-Support-NET-2-0