mailto with dynamic generated pdf - c#

We are working on Asp.net web application. As per requirement, We want to programmatically generate a pdf and need to send the generated pdf using “mailto:”(default email client) feature as attachment. Is it possible to send a generated email using “mailto” feature?.
We are stuck with this issue. Any help would be appreciable.
Best Regards,
Ranish

You can first save the generated pdf into a temp folder so that you can include this path into the attachment property.
<a href='mailto:name#example.com?Subject=SubjectText&Body=BodyText&Attachment="\\Path_to_the_temp_file" '>
A more better way would be to create a method that handles the sending of the mail.
Then you can use the MailMessage and the Attachment objects.
Namespace System.Net.Mail.Attachment

Related

Craft/Construct attachment using MailKit

I could not find this question anywhere.
Is it possible to craft attachment using MailKit without saving it local?
I have application linked to database and I am making Windows service for sending emails.
I read data from DB and I would like to craft .json attachment inside program and send it via mail using MailKit without saving that attachment local.
Thanks in advance.
MimeKit allows reading from and writing to MemoryStreams (and other non-File-based streams).
You can also construct messages where the content of attachments and such are stored only in memory and not on disk.
The BodyBuilder.Attachments collection allows adding attachment data as byte[] and Streams (which includes allowing MemoryStreams). The fileName parameters in these Add() methods is only to provide a file name to set on the attachment.

How do I send an embedded image email without ATT00001.bin file with c#

I am able to send email via smtp with c#, whereby inserting images with LinkedResource.
The problem now is that the emails received contain ATT0000X.bin files as attachment. How do I make sure these bin files are not added in the email?
Thanks in advance!
I just had this issue while trying to embed an image to the e-mail. I had two things wrong on my code, maybe one of them is happening to you:
First I was embedding an image but didn't define any tag for it to be displayed in my Body. This was fixed by adding into my HTML the tag cid:yourContentId and then assigning that tag as the image's ContentId. That fixed the issue in outlook, but it was still showing a clip like if the e-mail had an attachment, but no place to actually see the attachment. This looks super spammy. In Outlook web you could still see the ATT00001.bin attachment.
My second mistake was not defining the ContentType of my embedded image when creating the LinkedResource. This fixed the clip being displayed in the desktop client and in the web client no attachment could be seen anymore. The final code is something like this
LinkedResource embeddedImage = new LinkedResource(imageStream, new System.Net.Mime.ContentType("image/jpeg"));
embeddedImage.ContentId = "ContentId";
altview.LinkedResources.Add(embeddedImage);
mailMessage.AlternateViews.Add(altview);

How to Get the Attachment Type in an Outlook email using C#

i want to save the attachments of any outlook email into my local system along with their types (.text, .png, .jpeg)
how can i know the attachment type in C#
with regards,
vishnu
Read the Attachment.FileName property and extract the extension.

How to assign default From Account in eml files using c# for a MVC application

In my current MVC project there is a requirement to open a new outlook mail item by clicking a button with pre populated body and subject.
I have used the following method to achieve that:
1. Create a MailItem with requried details like Subject, Mail body etc
2. Using SmtpDeliveryMethod as SpecifiedPickupDirectory and create an eml file
3. Force the user to download and open the file in outlook
So far so good and EML file is correctly opening in outlook but the user has to manually select his mail account from the "From dropdown".
My question is there any way to assign the detault From account in EML files in order to open in Outlook 2010
The way I got around it, and it is way "hacky" to say the least, is to open the saved .eml in C# and delete all the from/sender values before streaming it down to the browser.
I have an aspx page that accepts a bunch of querystring parameters that allow you to customize the .eml output. You can't save the .eml file without a "sender" or "from" email address, so you need to save that out first - I use a dummy email account. You can use the SMTP pickup method or the MailMessage extension class to save the .eml file. Then I open the saved file, look for my placeholder email address (in the "X-Sender" header and "From" values), replace that with an empty string, then send the altered stream to the browser. The user never gets the "from" dropdown, it just uses the default account. Works like a charm.

Alignment of autogenerate mail using c#?

Is there any possible way to align the auto generate mail while upload a file to server. It sends the mail to admin what we upload in server like this
Hi All,
We have uploaded the following files onto FTP site. Details
are as below:
File name File size
D:\New folder\diff2.zip 172
I want to align this one in proper manner anyone help to resolve this..
Well you can save you email template in HTML file and Replace Tag after reading it.. E.g for above create the HTML as you want and then Replace the [[PATH]] Tag before sending email.
see this thread it may be help full for you.
Thanks

Categories

Resources