X
dnn.blog.
Back

Sending advanced emails

Sending emails in dotnetnuke is very simple with the one hit method Mail.SendMail(…) living in the DotNetNuke.Services.Mail namespace. But if you need more options like integrating images in the mail or handling HTML-, Text parts and attachments you need the direct Mail stuff from the .NET Framework.

Settings

First thing we need is reading the Host settings, because we want to use the SMTP server which is configured in dnn:

string smtpServer = (string)DotNetNuke.Common.Globals.HostSettings["SMTPServer"];
string smtpAuthentication = (string)DotNetNuke.Common.Globals.HostSettings["SMTPAuthentication"];
string smtpUsername = (string)DotNetNuke.Common.Globals.HostSettings["SMTPUsername"];
string smtpPassword = (string)DotNetNuke.Common.Globals.HostSettings["SMTPPassword"];</pre>

Our goal is now sending an email with a text part, a HTML-Part which has the sitelogo integrated and an attachment. Don’t forget to add System.Net.Mail to your namespace usings!

Lets create the mail object and add some address information:

MailMessage mail = new MailMessage();

mail.From = new MailAddress("\"My Name\" <me@myaddress.com>");
mail.To.Add("you@youraddress.com");
mail.Subject = "Hello this mail is from dotnetnuke";

Now let us create our first part, the plain text part of our mail. (If you want a special encoding, change the null to a System.Text.Encoding type)

AlternateView av1 = AlternateView.CreateAlternateViewFromString("This is the plain text part",null,"text/plain");

Next is adding our HTML part as a second AlternateView with our logo inside. In your HTML, you use “cid: as the source of the image. Then you add a linked resource and set the ContentId to whatever you set in your HTML image source.:

string htmltext = "Hello folks! <br> This is my new logo:  <img src="\"cid:Logo\">";
AlternateView av2 = AlternateView.CreateAlternateViewFromString(htmltext, null, "text/html");
string logoFile = MapPath(PortalSettings.HomeDirectory + PortalSettings.LogoFile);
if (File.Exists(logoFile))
{
	LinkedResource linkedResource = new LinkedResource(logoFile);
	linkedResource.ContentId = "Logo";
	linkedResource.ContentType.Name = logoFile;
	linkedResource.ContentType.MediaType = "image/jpeg";
	av2.LinkedResources.Add(linkedResource);
}

Now lets us add the AlternateViews to our mail and attach a file to it. Please be aware that the ASP.NET process (or the ASP.NET impersonated account) will need permission to read the file!

mail.AlternateViews.Add(av1);
mail.AlternateViews.Add(av2);
mail.Attachments.Add(new Attachment("c:\\temp\\example.txt"));</pre>

OK, Our mail is ready, now we can send it!

SmtpClient emailClient = new SmtpClient(smtpServer);
if (smtpAuthentication == "1")
{
	System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(smtpUsername, smtpPassword);
	emailClient.UseDefaultCredentials = false;
	emailClient.Credentials = SMTPUserInfo;
}  
emailClient.Send(mail);

As you see, this is no big deal and hopefully you start now sending out marvelous designed emails with attachments and integrated images that are not suppressed by the customers email client. A good resource if you want to know more about this is the website http://www.systemnetmail.com

Back
Total: 58 Comment(s)
Seeton
Well, I never had the need to send advanced emails but I guess I will have to know. I saw something about it onhttps://cheapessayservice.net/our-services/movie-review/ but since I did not know anything about it, I was worried. This really helps, thanks!
Saturday, November 3, 2018 · reply ·
geile weiber sex
Visit https://hausfrauensex.net/geileweiber for your own free sexy chat experience with hot young local girls!
Tuesday, October 6, 2020 · reply ·
best food in cozumel
I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks.
Tuesday, March 2, 2021 · reply ·
quentin1
Sending emails in dotnetnuke is very easy with a single hit method Mail.SendMail(…) living in the DotNetNuke.Services.Mail namespace. In case you want more options such as images in the mail, Text parts, dealing HTML and attachments you should have the direct Mail stuff from.NET Framework. I try to know about a site which is https://www.toptenwritingservices.com/7dollaressay-com-review/ and if anyone have suggestion or want to share experience then please do it.
Monday, November 5, 2018 · reply ·
David
I am glad to read it. https://www.sdfsd.com
Wednesday, December 19, 2018 · reply ·
aineabbas
I am glad to read it. https://www.sdfsd.com
Sunday, January 20, 2019 · reply ·
Anjali
Amazing blog with lots of information, thanks a lot for sharing this.
Wednesday, April 24, 2019 · reply ·
sdb
【丰胸产品】刘丽丽: https://1807614030.wixsite.com/fngzsite 那个时候我刚好失恋 ,很显然男人大多喜欢胸部大的 https://1807614030.wixsite.com/fngzgw 女生 ,那次失恋给我的打击很大 。我下定决心一定要丰胸 , https://1807614030.wixsite.com/fngzsite 也是很偶然找到粉嫩公主酒酿蛋 ,但粉嫩公主酒酿蛋没有让我失望 http://fngzmy.com
Thursday, July 4, 2019 · reply ·
how to give robux to friends 2019
Ask your friend what items he has for sale so you can buy one and donate Robux to him.
Friday, August 2, 2019 · reply ·
jothil
Ask your friend what items he has for sale so you can buy one and donate Robux to him. Record the names of the objects; Finding the name of an item is the fastest way to find it. https://robuxguide.club/how-to-give-robux-to-friends/
Friday, August 2, 2019 · reply ·
Lucille F. Parham
I just can’t stop reading this. Its so fresh, so filled with updates that I just didn’t know. https://summonerswar.io/
Saturday, January 11, 2020 · reply ·
Gayle
https://styleup365.net/watchcartoononline/">akashic records of bastard magic instructor season 2
Tuesday, January 14, 2020 · reply ·
Ask2Human
https://ask2human.com/">Customer Care Number
https://ask2human.com/">Ask2human
https://ask2human.com/listing/airtel-customer-care-number">Airtel Customer Care Number
https://ask2human.com/listing/bharat-gas-customer-care-number/">Bharat Gas Customer Care Number
https://ask2human.com/listing/hdfc-bank-customer-care-number/">HDFC Bank Customer Care Number
https://ask2human.com/listing/apple-customer-care-number/">Apple Customer Care Number
https://ask2human.com/listing/bata-customer-care-number/">Bata Customer Care Number
https://ask2human.com/listing/amazon-customer-care-number/">Amazon Customer Care Number
https://ask2human.com/listing/bookmyshow-customer-care-number/">BookMyShow Customer Care Number
https://ask2human.com/listing/caratlane-customer-care-number/">CaratLane Customer Care Number
https://ask2human.com/listing/chai-point-customer-care-number/">Chai Point Customer Care Number
https://ask2human.com/listing/cleartrip-customer-care-number/">Cleartrip Customer Care Number
https://ask2human.com/listing/croma-customer-care-number/">Croma Customer Care Number
https://ask2human.com/listing/expedia-customer-care-number/">Expedia Customer Care Number
https://ask2human.com/listing/ebay-customer-care-number/">Ebay Customer Care Number
https://ask2human.com/listing/firstcry-customer-care-number/">FirstCry Customer Care Number
https://ask2human.com/listing/flipkart-customer-care-number/">Flipkart Customer Care Number
https://ask2human.com/listing/goair-customer-care-number/">GoAir Customer Care Number
https://ask2human.com/listing/godaddy-customer-care-number/">GoDaddy Customer Care Number
https://ask2human.com/listing/goibibo-customer-care-number/">Goibibo Customer Care Number
https://ask2human.com/listing/goindigo-customer-care-number/">GoIndiGo Customer Care Number
https://ask2human.com/listing/grofers-customer-care-number/">Grofers Customer Care Number
https://ask2human.com/listing/homeshop18-customer-care-number/">HomeShop18 Customer Care Number
https://ask2human.com/listing/hotels-com-customer-care-number/">Hotels.com Customer Care Number
https://ask2human.com/listing/irctc-customer-care-number/">IRCTC Customer Care Number
https://ask2human.com/listing/ixigo-customer-care-number/">Ixigo Customer Care Number
https://ask2human.com/listing/jabong-customer-care-number/">Jabong Customer Care Number
https://ask2human.com/listing/jet-airways-customer-care-number/">Jet Airways Customer Care Number
https://ask2human.com/listing/koovs-customer-care-number/">Koovs Customer Care Number
https://ask2human.com/listing/lenskart-customer-care-number/">Lenskart Customer Care Number
https://ask2human.com/listing/limeroad-customer-care-number/">Limeroad Customer Care Number
https://ask2human.com/listing/makemytrip-customer-care-number/">MakeMyTrip Customer Care Number
https://ask2human.com/listing/myntra-customer-care-number/">Myntra Customer Care Number
https://ask2human.com/listing/naaptol-customer-care-number/">Naaptol Customer Care Number
https://ask2human.com/listing/nykaa-customer-care-number/">Nykaa Customer Care Number
https://ask2human.com/listing/ola-cabs-customer-care-number/">Ola Cabs Customer Care Number
https://ask2human.com/listing/pantaloons-customer-care-number/">Pantaloons Customer Care Number
https://ask2human.com/listing/paytm-customer-care-number/">PayTM Customer Care Number
https://ask2human.com/listing/nearbuy-customer-care-number/">NearBuy Customer Care Number
https://ask2human.com/listing/pepperfry-customer-care-number/">Pepperfry Customer Care Number
https://ask2human.com/listing/portea-medical-customer-care-number/">Portea Medical Customer Care Number
https://ask2human.com/listing/pvr-cinemas-customer-care-number/">PVR Cinemas Customer Care Number
https://ask2human.com/listing/quikr-customer-care-number/">Quikr Customer Care Number
https://ask2human.com/listing/redbus-customer-care-number/">Redbus Customer Care Number
https://ask2human.com/listing/shopclues-customer-care-number/">ShopClues Customer Care Number
https://ask2human.com/listing/shoppers-stop-customer-care-number/">Shoppers Stop Customer Care Number
https://ask2human.com/listing/rediff-customer-care-number/">Rediff Customer Care Number
https://ask2human.com/listing/snapdeal-customer-care-number/">Snapdeal Customer Care Number
https://ask2human.com/listing/xfinity-customer-care-number/">Xfinity Customer Care Number
https://ask2human.com/listing/usha-customer-care-number/">Usha Customer Care Number
https://ask2human.com/listing/oyo-rooms-customer-care-number/">Oyo Rooms Customer Care Number
https://ask2human.com/listing/zomato-customer-care-number/">Zomato Customer Care Number
https://ask2human.com/listing/spicejet-customer-care-number/">SpiceJet Customer Care Number
https://ask2human.com/listing/swiggy-customer-care-number/">Swiggy Customer Care Number
https://ask2human.com/listing/travelguru-customer-care-number/">Travelguru Customer Care Number
https://ask2human.com/listing/tripadvisor-customer-care-number/">TripAdvisor Customer Care Number
https://ask2human.com/listing/spectrum-customer-care-number/">Spectrum Customer Care Number
https://ask2human.com/listing/aakash-institute-customer-care-number/">Aakash Institute Customer Care Number
https://ask2human.com/listing/acc-limited-customer-care-number/">ACC Limited Customer Care Number
https://ask2human.com/listing/aol-customer-care-number/">Aol Customer Care Number
https://ask2human.com/listing/accu-chek-customer-care-number/">Accu-Chek Customer Care Number
https://ask2human.com/listing/urbanclap-customer-care-number/">UrbanClap Customer Care Number
https://ask2human.com/listing/acer-customer-care-number/">Acer Customer Care Number
https://ask2human.com/listing/intex-customer-care-number/">Intex Customer Care Number
https://ask2human.com/listing/bigbasket-customer-care-number/">BigBasket Customer Care Number
https://ask2human.com/listing/walmart-customer-care-number/">Walmart Customer Care Number
https://ask2human.com/listing/bharat-gas-customer-care-number/">Bharat Gas Customer Care Number
https://ask2human.com/listing/delhi-metro-rail-customer-care-number/">Delhi Metro Rail Customer Care Number
https://ask2human.com/listing/vijay-sales-customer-care-number/">Vijay Sales Customer Care Number
https://ask2human.com/listing/voltas-customer-care-number/">Voltas Customer Care Number
https://ask2human.com/listing/lg-customer-care-number/">LG Customer Care Number
https://ask2human.com/listing/rapido-bike-customer-care-number/">Rapido Bike Customer Care Number
https://ask2human.com/listing/jio-customer-care-number/">Jio Customer Care Number
https://ask2human.com/listing/yatra-customer-care-number/">Yatra Customer Care Number
https://ask2human.com/listing/verizon-customer-care-number/">Verizon Customer Care Number
Tuesday, February 11, 2020 · reply ·
Sophie Miller
Vielen Dank für die nützlichen Informationen! Ich half Ihren Rat! https://collegeadmissionscores.com/state/TX/
Thursday, March 26, 2020 · reply ·
Florida
Pretty! This was a really wonderful post. Thanks for providing these details. https://www.poolcreationsfl.com/copy-of-pool-resurfacing-sarasota
Wednesday, September 2, 2020 · reply ·
Summer Becky
Greetings! Very useful advice in this particular article! It's the little changes that make the most significant changes. Thanks a lot for sharing! http://www.capturealoha.com
Wednesday, September 2, 2020 · reply ·
ladies forum
You need to try https://hobbyladies.net/ladiesforum for your own free sexy chat pleasure with wonderful local girls!
Tuesday, September 22, 2020 · reply ·
sex in eisenstadt
Girls from https://nutten.at/burgenland are really the hottest around so check them today!
Thursday, October 1, 2020 · reply ·
Sophie Miller
Thank you for your work on the blog! You're doing a good job! https://dll.website/
Thursday, October 15, 2020 · reply ·
Sie sucht Sex Berlin
If you are looking for hot, young local girls you must vist – https://siesuchtsex.eu/berlin – for your own sexy chat pleasure!
Tuesday, October 27, 2020 · reply ·
안전놀이터추천
Wednesday, November 11, 2020 · reply ·
T4M Darwin
If you are alone and want to meet some sexy young girls you must try free hot chat for sex contacts - https://t4mdarwin.com/">T4M Darwin
Tuesday, November 17, 2020 · reply ·
sex offenburg
https://sexbw.net/offenburg is the web place with the best sexy ladies ready for free chat
Wednesday, December 2, 2020 · reply ·
sex in bocholt
https://sexnrw.com/sex-bocholt is the best place for lonely guys looking for hot ladies
Wednesday, December 9, 2020 · reply ·
saphiro
Way to go! this is exactly what I'm looking for! Keep posting. Awesome. https://www.pittsburghradonmitigationpros.com/
Monday, December 14, 2020 · reply ·
Click here
This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..
Saturday, December 26, 2020 · reply ·
Sex in Feldkirch
https://sexvorarlberg.at/feldkirch is great web place for hot chat all night long
Wednesday, December 30, 2020 · reply ·
osama shk
Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post. https://abonnenten24.de
Saturday, January 2, 2021 · reply ·
osassssma shk
Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.. Domótica
Sunday, January 3, 2021 · reply ·
osamas shk
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. digital marketing
Monday, January 4, 2021 · reply ·
osamsa shk
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. alquiler de carros cartagena
Saturday, January 16, 2021 · reply ·
osaSma shk
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. bridgend house clearance
Sunday, January 17, 2021 · reply ·
osaSma shk
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. bridgend house clearance
Sunday, January 17, 2021 · reply ·
osasma shk
Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. hartlepool removals
Sunday, January 17, 2021 · reply ·
osama shk
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help aHausautomation d wishing you all the success in your business.
Wednesday, January 20, 2021 · reply ·
osamas shk
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. tree surgeon colchester
Wednesday, January 20, 2021 · reply ·
osamass shk
Admiring the time and effort you put into your blog and detailed information you offer!.. covid cozumel
Saturday, January 23, 2021 · reply ·
osama shk
Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers. best diving in cozumel
Sunday, January 31, 2021 · reply ·
osamsa shk
I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up.. خانه هوشمند
Tuesday, February 2, 2021 · reply ·
Werneree
Sending emails in dotnetnuke is very simple and you provided a great article discussions about it. Thank you so much man, you always gave us such useful information that we can used when doing something in this programming language. Anyway, are you a video gamer by chance? Try this crossy road for pc https://crossyroad.onl/ today and start your arcade game experience with your friends. There are many things you can do in the game like customizing your characters. https://chrome.google.com/webstore/detail/toca-life-world/lmcaacacgcdhhodchambiananlcdpbai
Wednesday, February 17, 2021 · reply ·
osama shsk
Admiring the time and effort you put into your blog and detailed information you offer!.. teljes körű pályázatírás Debrecen
Thursday, February 18, 2021 · reply ·
osamsa shk
I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks. mobilház szállítás Németországból
Tuesday, March 2, 2021 · reply ·
best food in cozumel
I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks.
Tuesday, March 2, 2021 · reply ·
best food in cozumel
I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks.
Wednesday, March 3, 2021 · reply ·
nightlife in Cozumel
I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts.
Thursday, March 4, 2021 · reply ·
yucatan dishes
I high appreciate this post. It’s hard to find the good from the bad sometimes, but I think you’ve nailed it! would you mind updating your blog with more information?
Sunday, March 7, 2021 · reply ·
mat thew
Forum contributions are popular for me and you can visit https://free-solitaire.co">free solitaire an entertaining game site for you.
Wednesday, March 10, 2021 · reply ·
muneer ahmed
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. https://g.co/kgs/fq3Qfd">dentist in London at Hermes London Dental Clinic
Tuesday, March 23, 2021 · reply ·
muneer ahmed
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. dentist in London at Hermes London Dental Clinic[/url]
Tuesday, March 23, 2021 · reply ·
muneer ahmed
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. https://g.co/kgs/fq3Qfd
Tuesday, March 23, 2021 · reply ·
osamsa shk
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. luxury bathroom vanity
Sunday, April 4, 2021 · reply ·
osama shk
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. coronavirus mexico
Monday, April 12, 2021 · reply ·
osama shk
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. taroko tour
Thursday, April 15, 2021 · reply ·

about.me.

Torsten WeggenMy name is Torsten Weggen and I am CEO of indisoftware GmbH in Hanover, Germany. I'm into DNN since 2008. Before this, I did a lot of desktop stuff mainly coded with Visual Foxpro (see http://www.auktionsbuddy.de). 

I'm programmer, husband, father + born in 1965.

Please feel free to contact me if you have questions.

Latest Posts

DNN module development with Angular 2+ (Part 7)
6/10/2018 1:43 PM | Torsten Weggen
DNN module development with AngularJS (Part 6)
12/16/2016 7:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 5)
12/16/2016 6:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 4)
12/16/2016 5:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 3)
12/16/2016 4:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 2)
12/16/2016 3:00 AM | Torsten Weggen
DNN module development with AngularJS (Part 1)
12/15/2016 7:19 AM | Torsten Weggen
Blogging in DNN with Markdown Monster by Rick Strahl
11/27/2016 1:14 PM | Torsten Weggen
Creating a global token engine
11/18/2016 10:25 AM | Torsten Weggen
DnnImagehandler - Hot or not ?
2/21/2015 11:52 PM | Torsten Weggen

My Twitter

Keine News gefunden!