Getting view as string in asp.net mvc for email sending - asp.net-mvc-3

I want to use Mailgun (or maybe Sendgrid) to send emails from my app.
This is pretty straightforward cause I can use RestSharp to interact with their api.
The problem lies in the fact that generating an HTML email is a PITA if I cant use razor.
I know there are two nuget packages (Postal, MvcMailer) that handle this problem quite nicely but they force me to use a SMTP server and I dont want or need that at all.
I just want to keep using the Mailgun API to send emails but I want to have a way to generate the markup for those emails using Razor.
How can I do this?
Please Help.

If you have a partial you can render it to a string, as in the following SO question: link

Related

Opening an Outlook Email

I am not new in computers; I am a .NET developer, but was presented with this great opportunity to develop in PHP, so I took it. There is a need to open an Outlook/Item (email) form the website; is that even possible? I know there is functionality in CakePHP to send emails but client wants to use their own Outlook application.
Any pointer would be much appreciated! Have a great coding day...
There ist no easy Way in PHP. PHP will be executed on a webserver and not on the client computer.
There ars some ways to solve this, depend on your needs:
You can open the standard mail-client with an HTML-Link like this:
E-Mail senden
If this is too rudimentary, you can send an nice formated email via smtp/sendmail to an emailadress.
cakephp mailer class documentation
You can also try to connect via IMAP an put mailobjects into the draft-folder. There are some basic PHP functions for this: PHP IMAP documentation
Only in the first case, outlook will open the email in a Window.

Mailchimp Dynamic Content: add customized link in subscribe email

We want to start a service with Mailchimp where every subscriber will get a customized link in the email she receives. The Subscription Form will be on a wordpress website (not my decision).
There is a pool of thousand of links with a unique parameter, which we have stored on our webserver, like these examples
https://example.com/link?code=a25b1d085f3aec4b256
https://example.com/link?code=32219abb336de28a103
etc
Every code parameter should only be used once and should be kept as secret as possible. So I don't think it is a good idea to send the code from the form to mailchimp in a hidden field.
I don't know, if this is possible. Is Mailchimp even the right tool to do this?
I'm not sure, where to start the journey.
I don't think webhooks will help me here, as those are only one-way communication without a backwards channel, as far as I understand.
I checked the Mailchimp API documentation, but I might be too foolish to understand, which of the multiple options I need to use.
I found this answer here: https://stackoverflow.com/a/53096852/476951, but I don't know, if this will suit my needs. As I understand it, this will chhange the mail template in Mailchimp UI with an API request and store it. The successive emails will all use this changed template until I change the template again. This seems not to be the correct way.
So, here are the two workflows that might be possible, but I don't know if they are.
Have a form created in Wordpress (not the embedded Mailchimp form), and create a custom form handler with admin-post.php like described here. Then use the API to send the email through the Mailchimp service with my dynamic link in it. But how. Every tuorial I found sends campaigns via the API, not individual mails to single recepients
Somehow manage Mailchimp to get the dynamic content via some sort of webhooks or the likes.
Is any of these workflows suitable to do this?
If yes, who should I set these up?
Is there anything else I might have missed?
Edit
Or do I need to use Mailchimp Transactional Email service (former called Mandrill)?

How to receive sms on asp.net using nexmo service

I need some guidance on what steps I should follow to receive sms messages using service from www.nexmo.com.
I am not familiar with asp.net but I am very familiar with C# on windows, so please if you can provide a few steps to get me going then I can pick it up from there. Right now I have an account at www.godaddy.com, so I am hoping I can write the code to place it there. I don't really need much details on how to use nexmo service, I mainly need to know what I should do on my web site to receive sms from nexmo.
Incoming SMS's are simply HTTP requests to your 'page'. Nexmo send's the SMS and related data just like a HTML from submits data to a URL using a GET (query string) or POST (form encoded),
So all you have to do is point Nexmo to the URL you want to use, and check the incoming request for the data. Here's the documentation for incoming messages.
Here's a community authored C# library that might be be helpful.
(Disclaimer: I do a bit of developer evangelism for Nexmo.)

Improving WebMail performance MVC3

I'm using the MVC helper WebMail to send emails. However the speed of it seems to be of concern. Especially when I have to send more than 1 email at the same time. I tried using a thread, but that didn't work since the Webmail object was null. How do I speed this up? Any ideas appreciated.
Forgot to mention, this is during testing and I'm using localhost and gmail! Not sure if that is causing the issue.
Thank you
If you want performance, don't use the WebMail helper. Use the classes in the System.Net namespace.
This allows you to open a new thread and send the email out-of-band from the web request.
We use Google Apps mail (gmail) in the cloud, opening a new thread, and sending the email from there, using the System.Net types (not WebMail). It works pretty well, as we can respond to the user without having to wait for the email to be sent.
Be careful about using Google Apps / gmail though, especially in development. We had one of our accounts disabled by google because of this. During development, you should use your local ISP, or better yet, use SpecifiedPickupDirectory, as it works better when unit testing email receipt.

Using MvcMailer in non-MVC project

I have a windows service that is supposed to send e-mails periodically.
Next to the windows service project there is an MVC 3 project that is sending e-mails with MvcMailer (beautifully).
I want to use the same engine to send e-mails for the windows service.
How should I do it?
Import the MVC binaries and create one controller and new views for this purpose? Will it work?
Saving it in the database and requesting my web project to send the e-mail might not be the best solution because the information is the result of a query and is too big to be sent in the request.
The only other option I see is to simply request the web project to do all the work but this way it wouldn't be beneficial to place the windows service in another service to save the site application resources.
How would you do it?
As an alternative to MVC Mail, ActionMailer.NET can now be used stand-alone outside of MVC.
The details are covered here
http://geeksharp.com/2011/07/06/actionmailer-0-6-released/
I would argue that calling a mvc mailer from the service might be an overkill. If the mvc project is supposed to expose sending the email API for all of your other solutions, then building a REST api might make sense. However, if you just want to bring the functionality of the action method to the windows service, then i would choose an in-process functional component. If you can refactor the logic of the mvcmailer action method into another assembly why not just do that and then include that assemlby as a depedency in your windows service solution.
If you can provide the over all purpose of the mailer and how it's used in the web scenario, it may help us to provide a better architecture.
Why do you think the query to send to mvcmailer us too large? If you have the mailer MVC project already working and exposed via a restful URL, that becomes your email service and simply call it as a web request from your service.
You can get around size constraints in your request That shouldnt be an issue.

Resources