Alignment of autogenerate mail using c#? - 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

Related

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);

Using HTML file as mail body template, images are not showing

I am trying to use a HTML file as mail body template. HTML file has few inline images like LOGO. Everything is fine and I am getting all contents in the HTML file upon receiving the mail, except the images.
An example below src="~/Images/logo.png" but after getting the mail, if I view source in mail client I see like below (using Google SMTP server to send mail).
Reason is pretty clear as why images are not getting displayed (due to the fact that src part is getting changed) but not sure how to avoid this.
<img title="MyCompany" class="xxxx" alt="MyCompany"
src="https://ci4.googleusercontent.com/proxy/VigKoQr9DXTS3UveuswmpxB6iEAO5rcVwSrrVUptfWGAeYQFugjcKDZxDZbB6g=s0-d-e1-ft#http://~/Images/logo.png">
Any solution for this? How can I get the actual images being displayed?
Thank You.
Here the solution!
For email template you should provide absolute url for the image.
Ex: <img src="http://ngm.nationalgeographic.com/2015/11/climate-change/which-species-will-thrive/img/12-bengal-tiger-1024.jpg" >

mailto with dynamic generated pdf

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

Add image in email not as linked resource but should be visible in outlook

I want to add image to email. I tried several ways the final solution I am having is to add image as linkedResource but it will increase the size of email and I don't want that as email is already having several attachments.I am using xslt file to get html body of email from XML input. I am adding the image as following
<img src="http://placehold.it/350x150">
but somehow the image is shown as red cross in outlook client in microsoft office and in .mht file.Emails look fine in outlook webmail client and on different browsers.
If I see the network tab in browser after I open the mail in browser from outlook client in microsoft office the request can be seen for url 'http://placehold.it/350x150' but received bytes are zero and response is blank.
Is there any way to add image to email without using linkedResource?
Your help will be really great to me.
Encode the image using base64 and add like this:
<img src="data:image/JPEG;base64,{encoded string}">
Where the {encoded string} part is a base64 encoding of image data. JPEG can be gif or whatever according to type of image.
You could use embedded images.
<img alt="My Image" src="data:image/jpeg;base64,/9j/4S/+RXhpZgAATU0AKgAAAAgACAESAAMAENkDZ5u8/61a+X...more encoding" />
More info here: https://sendgrid.com/blog/embedding-images-emails-facts/
PS. A while ago we have an problem with email rendering in different browsers and email clients. And storing images as described was the best solution (for images, ofc :)).

Images don't appear in emails

I have a HTML email template in the App_Data folder of my MVC application. In my code, I use this template to send HTML emails to users. This template references a few images in a folder in my project. The issue is that these images don't appear at all when the user receives the email. I have tried to reference the images using ~/path to image/image.gif. I have tried using ../../path to image/image.gif and I have copied the images to the App_Data folder and just referenced the images thus image.gif. Nothing is working. Does anyone have any suggestions?
the images either need to be stored in a publicly accessible location with a full reference to the image <img src="http://my.domain.com/images/filename.ext" /> or the images need to be embedded into the email.
The reason behind the image is not show in email because email client cannot get path you
specified.
For the solution you can do below
First replace the simple image URL to publically access url
[means if you copy the image URL in browser you can access the browser], make sure your image folder is out of authentication
As Jason said you have to put whole url, but if you put your image in App_Data they won't be accessible from outsite because this is a protected folder. You have another option to put images in mail, IMO this is a prefered way to put images in mail, e-mail client won't complain and ask for permission to display images. Here is a example how to do this
http://www.codeproject.com/KB/aspnet/EmbedImage.aspx
you can also use google picasa.
upload the images to picasa, set the visibility to public, get in the album and on the right
side you will have link to this photo link.
press this link and chose the size you want it to be displayed, mark the image only
check box and you will have a link ready to embed in to the mailer.
put the link in the src and that is it.

Categories

Resources