Hell guys,
I'm coding in csharp to send an email which contains a .zip file (has htmls and css inside). When I check the mail recieved, In fact, instead of the .zip file, the attachment becomes a txt file and has:
FILE QUARANTINED
The original contents of this file have been replaced with
this message because of its characteristics.
File name: 'xxxxxxx_Result.zip'
Virus name: 'Large uncompressed size'
The exchange server has blocked the zip file..I'm using CDO to create and send the email.
I tried using the code to send a mail with a zip file generated by WINZIP, there was no problem, then I tried using outlook to send a mail with the zip file generated by my code(I use sharpziplib library), the problem occured...
How can I do to send the attachment correctly? Many thanks in advance!
Allen
I encounter similar problems sending email on our network. I've found that using an alternate compression format, such as 7-zip (.7z), is adequate to get my content through the filters. This could resolve the issue if the block is not due strictly to size.
Looks like your mail server or spam service have removed your attachement and replaced it with the txt file, it sounds like your code is fine and you need to speak to an admin regarding the mail filters and send size quotas!
For anyone facing this problem, here is a solution. You have to explicitly set the file size for the zipentry.
ZipEntry newEntry = new ZipEntry(fileName);
newEntry.DateTime = DateTime.Now;
newEntry.Size = fileData.Length; // setting data size
Related
I'm working on an issue to my project that when I click the button, a default email client should pop out and if there's an attachment, it should be automatically attach to the default email client like this.
I already tried a lot of methods how to do this. First I used MAPI, but the MAPI cannot detect my Default Email Client even though I already set it in Control Panel, It shows this two message box
I already searched the internet about those error but there's no definite or clear answer to me. HERE'S the code I used in MAPI.
I used also the mail:to protocol to call the default email client who's handling to the aforementioned protocol with using this line of codes.
Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process()
Dim filename = Convert.toChar(34) & "C:\USERS\JOSHUA~1.HER\DOWNLO~1\ASDPOR~1.PDF" & Convert.toChar(34)
Debug.Writeline(filename)
Dim asd As String = String.Format("mailto:someone#somewhere.com?subject=hello&body=love my body&Attach={0}", filename)
proc.StartInfo.FileName = asd
proc.Start()
But still, no luck. I read a thread that the mail:to don't handle attachment anymore, but this line of code opened my default email client with body and subject, but there's no attachment. In terms of the filename variable, I already tried every path format, I read that I should use 8.3 path format. But still doesn't work.
The last method I used is extending the System.Net.MailMessage.MailMessage() following THIS answer. This works in terms of opening the default email client and attaching an attachment to a mail, but this is not editable and there's no send button on the default email client because this line of code just generating an .eml file and opening it. I'm thinking of parsing the eml file but still I don't know how to open the default email client progmatically in a new message form. Here's the photo
You guys have any idea how to make this possible? Thanks!
I am afraid that this will not be possible to do using some generic method for any mail client. But you can easily create your own solution using System.Net.Mail.SmtpClient and some simple custom UI.
Currently, I have an email application and I want to add send messages with .eml but not as attached file without from, to content. I don't know where to start. My first idea was extract message from .eml file and return CDO message.
It would be possibly looking at the OpenPop.NET library (http://hpop.sourceforge.net/). MIME parsing is included and, as far as I can remember, functioned OK for me once. I have the impression that this is what you are looking for.
In my application, i send mails to managers from program automatically. Normally it works good, but when i use program on another computer, it sends mail automatically but file type is not PDF. File type is File and name of pdf is =utf-8BQU5HT1JBIEhBTEkgQS7Fni4gR8OcTkzD. I also checked source codes. But I couldn't understand what is wrong with that. Any idea what to do?
Try to fill the ContentDisposition, example is here:
Sending email with attachments from C#, attachments arrive as Part 1.2 in Thunderbird
Maybe, in the code you can change the MediaTypeNames.Application.Octet to MediaTypeNames.Application.Pdf
I hope, this helps!
I am trying to develop an outlook add-in in VS 2010. It's purpose is to scan email body and attachment content for some key words and if any such words are found, email sending should be blocked.
I am able to read email body and subject and to the validation but I am not understanding how to read an attachment content (txt file) while composing the mail.
attachment.GetTemporaryPath() is not giving the attachment path. I guess this works only for mails in inbox.
One way I found was saving the attachment to a temp folder and reading it (attachment.saveAs()).
Is this the only way to read attachment content while composing a mail ?
Possible Duplicate : C# Outlook 2007 - How do I access attachment contents directly from my addin?
But as suggested in there, I cant use Redemption. Is there any other way?
Yes, saving the attachment data to a temporary file and reading it s the only way. In theory, you can use Attachment.PropertyAccessor.GetProperty to read the PR_ATTACH_DATA_BIN property, but you will run into problems for the large (> 64kB) files.
You can also use Extended MAPI to open the attachment data as IStream (IAttach::OpenProperty(PR_ATTACH_DATA_BIN, IID_IStream)), but it is only accessible through C++ or Delphi. You can use Redemption (any language - I am its author) that wraps Extended MAPI and exposes AsArray and AsText properties on both RDOAttachment and the Attachment object exposed by the Safe*Item objects.
Am processing emails using exchange web services. Is new to me but this works fine, however I've come across a 'feature' I can't resolve.
I have to save the emails to disk, so I do in the eml format using:
File.WriteAllBytes(fileName, email.MimeContent.Content);
Sometimes the emails I process have an msg file attached to them, but when I load the saved eml file, I see the msg attached is now in eml format as well.
How can I keep an msg attachment as an msg attachment when saving to an eml file?
How are you setting the filename? Can you check the original attachment format/extension and then save the new one with the same extension?