I am using this library IMAPX to get emails.
I also need to send emails but cannot figure out how.
I tried using the example code:
client.Folders["INBOX"].AppendMessage(msg)
but receive an error that AppendMessage requires two arguments and I cannot figure out what the second argument should be.
Is it possible to send an email with this library and if so how?
According to Reflector, it looks like the second parameter should be a string giving the flags for the new message; it looks like the ImapFlags class gives a list of available flags.
If you want more background in IMAP, then you should read its RFC.
However, the IMAP protocol is NOT used to send mail, it's used to read or retrieve mail that's in a mailbox on a server. You can use it to add messages to your own mailbox (as you're trying to do here), but that isn't what most people mean when they talk about sending email... SMTP is the standard way to send email.
Related
I am using GraphAPI for sending email. I have a situation where I need to Save a copy of the email sent. I can retrieve the Messages using graph api. How do I identify the email I just sent? When I use the SendEmail endpoint of the Graph api, I get a 200 OK response. How do I identify the email I just sent so I can download that email?
I have tried a number of solutions, adding custom Identifiers and filtering it but none of them worked.
I haven't tried this, but this approach seems it would work: https://learn.microsoft.com/en-us/graph/outlook-immutable-id#immutable-id-with-sending-mail.
Create the message as a draft with Prefer: IdType="ImmutableId" header
Save the returned id
Send the draft
Note that email sending is asynchronous so you might not be able to download the sent email right away. It could take some time to be available.
I have difficulties implementing the following scenario.
Let's say you have a web site with ability to send and recieve messages between users.
User recieves an email with notification he has a new message on the software system (doesn't matter in what it is implemented). He can respond to this message by sending a reply via email or by logging into the site and replying to the 'message' using the site.
In case of the first approach if user simply replies to the email notification, how can you (as a developer) know what 'message' (ID) is the reply for?
I'm thinking the info would be stored in the MIME extensions. Are the MIME extensions transfered to the reply of the message? If yes than the solution could be to see the data of the original message notification for wich the user replyes to.
Any ideas? Thank you
The only “reliable” way would be to encode that information in the sender's address to which the user replies; you could also put it into subject or body of the message, and “hope” that the user doesn't tamper with it. There is an “in reply to (message-id)” header, but a lot of existing eMail clients don't set the header properly.
The usual mechanism is something like this: create an eMail alias prefix, and the append a message-id-code fragment to the end; for example, if this was for a purchase order confirmation, you could create an eMail alias handling addresses of the form po-*#example.com, where * is the unique message ID. Then, when you send your message out, you'd put the appropriate address in both the From: and Reply To: headers. EG:
From: "Purchase Order Confirmation (#1234)" <po-1234#example.com>
To: "John Doe" <jdoe#example.com>
Reply-To: "Purchase Order Confirmation (#1234)" <po-1234#example.com>
Subject: Confirm your order (#1234)
Depending upon your mail server, you should be able to define a “separator” character (typically - or +) that is used to split up the parts of the “local part” (left of #) of the eMail address; there is typically then another mechanism to map a prefix to a script to handle all addresses of a certain form. The script interface is often very much like CGI on the web, sending in some environment variables and piping the message itself in on the standard input. If your app is primarily web-based, you might find it more “comfortable” to gather the incoming eMail body, and POST it to a private (perhaps http://[::1]/getMailReply) handler. This may help you reuse existing code more readily.
We have set up a catch-all email address on our server - for example catch-all#myserver.com. When we send emails to users, we encode the message id and any other meta information we may need in the from address. You can obfuscate this or not, depending on what your needs are. So, for example, if the user has a new message in the system whose ID is 100, the from address of the email we send to the user would be something like reply-to-message-100#myserver.com. Make sure that whatever format you use for the from address would never generate a real email address on your mail server.
So, when the user responds to this message, it will get sent to the catch-all inbox you have set up. From here, you have a number of choices to make on how you process this email. In times past, we wrote a little scheduled service that would run every few minutes and check this inbox for new emails, process them as you like (insert into db, send more emails, whatever), and delete the message since you're done processing it. This is fragile since email clients all have slightly different ways of sending emails and it becomes difficult to parse the variety of client messages out there.
The second way we've done it is by integrating with http://postmarkapp.com/ - which has an incoming email api that should go public soon (we got in on the beta). You'd set everything up the same way only make your server's catch-all address forward to the postmark incoming address you'll set up with Postmark, and then Postmark does the message processing and calls a webhook you also set up to do what you like with the object received.
I highly recommend Postmark, but even the homespun method worked effectively, for the most part.
-M
Just a followup to the previous answer, Postmark Inbound is now live and public http://postmarkapp.com/inbound For each email sent to your specially formatted inbound email address, you'll receive a JSON formatted web hook API call with all the email components, headers, attachments sorted for you.
I am trying to find a solution that can handle messaging via email.
When a user creates a message in my application, an email is sent using subject #4857474.
Then, the email recipient can reply, without changing the subject, and my application would know what message it used, based on the #id in the subject.
Now, I do not want to implement such service because its rather complex. What I am looking for is a service that provides this, and just calls my web services for a request when a new message has arrived.
Is there such thing? Thanks!
In the smtp standard there are two header fields that can be used for this: message-id and in-reply-to.
Assign a unique message id when you send the mail, then inspect the in-reply-to field in messages you receive. Since the field is hidden from user input, there is no risk that the user messes with it.
I don't think there is a default component you could use. Also it wouldn't be a very complex flow i think.
Just read out the subject and trigger your app?
Is email a must or can you also use a webbased reply form? Then you could use just a database.
Edit:
Read email from C# http://www.codeproject.com/KB/IP/despop3client.aspx
Create a thread that runs for ever and reads out the mailbox. If a email matches your criteria (subject) then trigger your webservice.
I have created a simple asp.net email form for a client, which is sending off emails using the SmtpClient class. It is very basic and works in most instances.
The form is used in a number of websites but it only works intermittently. The code always works and does not throw any exceptions, it just works correctly but intermittently and for certain clients, the email never reaches the To address. If changes to an external email (e.g. my personal Hotmail account) it works correctly.
We have asked the recipients to check their spam inboxes but to no avail. How would one be able to track this issue? How can I know that my clients asp.net server has sent the email (in which case the problemm is at the recipients end) or not?
Look at the headers in the e-mail you got in your hotmail account and see what the From: and Reply-To: fields are set to.
Then look through your source code to compare with what you're asking it to be set to.
You might be getting a bounce message from an SMTP server (yours or another one en route to the destination) and it might be sent to the From: address of the e-mail.
Check that you have code to handle exceptions, test with incorrect details and see what StatusCode returns.
Do you have control over the SMTP server, so you can access its logs and see what's going through it?
If not, can you set up an SMTP server that you can control, which just passes email on to the real server, but logs things.
Do you have the sender address set to something valid, so you can see if there are any failure messages coming back?
No answers, I'm afraid, but perhaps the questions will give you some ideas that may help.
If your clients are using Exchange server, then you can use message tracking to see what happened to the message. If they are using the built in IIS SMTP server, you can enable logging to see what is happening as well. Like the first post mentioned, check you message headers and make sure they are valid...
Can you access the mailbox that belongs to the From: address. Any delivery errors will be sent to that address.
If the From address doesn't exists, then that's a probable cause that the mail is not delivered. Some mail server check if the from address exists, in an attempt to block some spam.
I need to send MMS thought a C# application. I have already found 2 interesting components:
http://www.winwap.com
http://www.nowsms.com
Does anyone have experience with other third party components?
Could someone explain what kind of server I need to send those MMS? Is it a classic SMTP Server?
Typically I have always done this using a 3rd party aggregator. The messages are compiled into SMIL, which is the description language for the MMS messages. These are then sent on to the aggregator who will then send them through the MMS gateway of the Network Operator. They are typically charged on a per message basis and the aggregators will buy the messages in a block from the operators.
If you are trying to send an MMS message without getting charged then I am not sure how to do this, or if it is possible.
You could do it yourself. Some MMS companies just have a SOAP API that you can call. All you need to do is construct the XML and send it off via a URL. I have done this once before, but can't remember the name of the company I used.
This post earlier discussed different approaches for SMS and might be helpful for you.
You could use Twilio to accomplish this. You can dive into the docs for specific implementation details but using the C# helper library the code to send an MMS would look like this:
// Send a new outgoing MMS by POSTing to the Messages resource */
client.SendMessage(
"YYY-YYY-YYYY", // From number, must be an SMS-enabled Twilio number
person.Key, // To number, if using Sandbox see note above
// message content
string.Format("Hey {0}, Monkey Party at 6PM. Bring Bananas!", person.Value),
// media url of the image
new string[] {"https://demo.twilio.com/owl.png" }
);
Disclaimer: I work for Twilio.