Capture webpage as image send via email - c#

How do I capture a webpage as an image and send it embedded in an email.
This is what I want to do.
Users are logged on this website. They will be browsing many products, when they click on the email button the webpage containing the list of products will be captured and send to their email address embedded in the body of the email.
Technology I would like to use:
C# .net
The customers' information is stored in a SQL server database.
I have been experimenting with web browser control, but I don't know if that will work.

Is it important that the "capture" is actually a physical image or is the content of the order what's most important? If you can send the content of the order, i.e. the order lines, you can just put the exact same HTML as you output in the browser in the e-mail you would like to send, using the MailMessage class:
using (MailMessage message = new MailMessage("from#example.com", "to#example.com"))
{
message.Subject = "Your order";
message.Body = "<ul><li>Your</li><li>Order</li><li>Lines</li><li>Here</li></ul>";
message.IsBodyHtml = true;
using (SmtpClient smtp = new SmtpClient("smtp.host.example"))
{
smtp.Send(message);
}
}

You can capture the webpage as a quality image with a screenshot extension from the chrome web store that can be installed for free. You will be able to capture either the visible screen, full-page or custom area capture within a few clicks. Once the image has been captured, you can save it as a PDF or PNG and then use the saved image to be sent over by mail to the concerned party.
One such tool you can use could be the Goscreenshotting - Screenshotting extension which can help you save screenshots in multiple ways and formats to be shared over mail or any other medium.
You can also capture the webpage with the stock app on Windows - Snipping tool. But this will only allow for visible screen and custom area snips and not the full screen capture.
If you are using Mac OS, you will be able to capture the screen with the following shortcuts :
Command + Shift + 3
Command + Shift + 4
Command + Shift + 5

Related

How to open default email client with attachment

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.

Windows phone sdk send email with XNA game engine

I am making a game for my windows phone, using Visual Studio 2012 for Windows Phone and it went good from there, I wrote a few classes, and added assets but I encountered a problem.
I wanted to make a bug request / idea method, but no-where could I find where to email with XNA. I searched on Google but it came up with stuff like "How to use XNA game studio" and at the bottom it said stuff like "email us" so I never found it out. Basicley I couldn't find it. Can anyone help me out?
You can send an email out using the EmailComposeTask class in WP8. But it not totally automatic, the user has to select the account to send the email with then the Email display pops up then they have to click on send button. You can try it like this:
How to use the email compose task for Windows Phone 8
using Microsoft.Phone.Tasks;
// do this when the page has load completely (not in the constructor)
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "message subject";
emailComposeTask.Body = "message body";
emailComposeTask.To = "recipient#example.com";
emailComposeTask.Cc = "cc#example.com";
emailComposeTask.Bcc = "bcc#example.com";
emailComposeTask.Show();
However, I don't think this is what you want. What I would do instead because it's difficult to do the email thing silently is create a webpage, that you can POST to. You then can just open a WebClient and POST the data that you need to that website. Then on the website's back end, just decode the POST[DATA] into a database.
Hope this helps you, good luck.
As mentioned in the other answer, you may want to consider just opening a web page with a form for them to fill out, rather than writing emails within your app.
If so, here is the code to open a webpage on Windows Phone from an XNA game (using http://www.google.com/ as an example.:
WebBrowserTask browser = new WebBrowserTask();
browser.Uri = new Uri("http://www.google.com/", UriKind.Absolute);
browser.Show();

Send location with message on windows phone

I am developing an app and would like to attach my location to a message and make this location "clickable" so that they can see it on a map/get a link which opens a map.
I am getting the correct location and store it into currentPosition but I am not able to send it so that the user can click on the link/map and see where I am. Is this even possible with the Windows Phone
var smsComposeTask = new SmsComposeTask();
var message = Message;
message += string.Format("\r\n My location is\r\n {0}",_currentPosition);
smsComposeTask.Body = message;
smsComposeTask.Show();
I think this is not possible because SMS body is plain text. It would depend on the receiver's sms app implementation, whether it recognizes location in sms body or not. For e.g. if you send a phone number or link in plain text in sms, it appears as a clickable number or hyperlink to the receiver only if his/her sms app displays it as such. Also i think wp8's native sms app uses mms to send location and there is no api to send a mms.
you can send it by using a link composer. So when you have found the position you should send it as a link. You can try and look at the app "I'm Here" in the store.

How to include the user signature in the email body when sending a customized email through Thunderbird, using C# 3.5?

We need to send email from our desktop application using C# 3.5. The requirement is to send the new email using the Thunderbird, not directly from our application. So we are setting certain properties for the new email like emialfrom, emailto, subject, body & attachments through code, we save it as an .eml file & then we open that .eml file in thunderbird using code:
The logic we are following is:
MyEmailClass eml = new MyEmailClass();
eml.Subject = "subject";
eml.SetHtmlBody(" email body");
eml.From = "from";
email.AddTo = "toemail#domain.com";
email.AttachmentPath = "attachmentpath";
email.SaveEml("myEmail.eml");
So now we have the the .eml file & we need to open it in the Thunderbird, we are using System.Diagnostics.Process.Start to open the eml file in Thunderbird:
System.Diagnostics.Process.Start(thunderbird exe path,myEmail.eml path);
The above works fine, however we have just one issue, the sender signature is not shown when the email opens in the Thunderbird.
Facts:
1- The user has valid signature associated with his account.
2- We are using Thunderbird 8.0
3- We are using C# 3.5
4- Thunderbird is the default email client on users systems.
Signatures are added by the email client when it creates the email body. Since you are creating the email body through code, you would have to programmatically insert the signature. Just to be clear, you are not necessarily launching thunderbird on the user's machine, you are launching whatever process is associated with the .eml file extension. If you want to include the singature from Thunderbird, you could look to see if any of their APIs help, but they look like they haven't been updated in years. You could also give your users the option of setting up their signature within your application.

Generate an e-mail to be downloaded by client and sent from their outlook account

One of the requirements for the application that I'm working on is to enable users to submit a debugging report to our helpdesk for fatal errors (much like windows error reporting).
I've been told that e-mails must come from a client's mail account to prevent the helpdesk getting spammed and loads of duplicate calls raised.
In order to achieve this, I'm trying to compose a mail message on the server, complete with a nice message in the body for the helpdesk and the error report as an attachment, then add it to the Response so that the user can download, open and send it.
I've tried, without success, to make use of the Outlook Interoperability Component which is a moot point because I've discovered in the last 6 hours of googling that creating more than a few Application instances is very resource intensive.
If you want the user to send an email client side, I don't see how System.Net.Mail will help you.
You have two options:
mailto:support#domain.com?subject=Error&body=Error message here...
get user to download email in some format, open it in their client and send it
Option 1 will probably break down with complex bodies. With Option 2, you need to find a format that is supported by all mail clients (that your users use).
With option 1, you could store the email details locally on your server against some Error ID and just send the email with an Error ID in the subject:
mailto:support#domain.com?subject=Error 987771 encountered
In one of our applications the user hits the generate button and it creates and opens the email in outlook. All they have to do is hit the send button. The functions is below.
public static void generateEmail(string emailTo, string ccTo, string subject, string body, bool bcc)
{
Outlook.Application objOutlook = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)(objOutlook.CreateItem(OlItemType.olMailItem));
/* Sets the recipient e-mails to be either sent by 'To:' or 'BCC:'
* depending on the boolean called 'bcc' passed. */
if (!(bcc))
{
mailItem.To = emailTo;
}
else
{
mailItem.BCC = emailTo;
}
mailItem.CC = ccTo;
mailItem.Subject = subject;
mailItem.Body = body;
mailItem.BodyFormat = OlBodyFormat.olFormatPlain;
mailItem.Display(mailItem);
}
As you can see it is outputting the email in plaintext at the moment because it was required to be blackberry friendly. You can easily change the format to HTML or richtext if you want some formatting options. For HTML use mailItem.HTMLBody
Hope this helps.
EDIT:
I should note that this is used in a C# Application and that it is referencing Microsoft.Office.Core and using Outlook in the Email class the function is located in.
The simple answer is that what you are trying to achieve isn't realistically achievable across all platforms and mail clients. When asked to do the improbable it is wise to come up with an alternative and suggest that.
Assuming that your fault report is only accessible from an error page then you've already got a barrier to spam - unless the spammers can force an exception.
I've always handled this by logging the fault and text into the database and integrating that with a ticketing system. Maybe also have a mailto: as Bruce suggest with subject=ID&body=text to allow the user to send something by email.
I don't think an .eml format file will help either - because they'll need to forward it, and most users would probably get confused.
A .eml is effectively plain text of the message including headers as per RFC-5322.

Categories