SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using xp_readmail to read mail from outer environment


Using xp_readmail to read mail from outer environment

Author
Message
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5166 Visits: 4076
HI

Is there any way to read the (Inbox) mails from exchange servers(outside the sql server)? my first requirement is whenever i get any mail ion my mailserver on, lets say "support@abc.com" with subject "master population" then i will get
notification mail on other email address says "bkumar@abc.com" .

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Jayanth_Kurup
Jayanth_Kurup
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2897 Visits: 1351
I remember doing something very similar in SQL 2000 with xp_readmail ( FAQ email helper - customer emails inbox with subject line HELP and we query the DB for related articles and reply to them links). But I think the correct approach here is to code in .Net or somether programming language , probably create a service which polls the Exchange server and do it that way.

Jayanth Kurup
Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14803 Visits: 14396
xp_readmail is for SQL Mail, which is deprecated.

In my opinion this kind of work should be done way far away from the database engine. There are many applications out there that will monitor an inbox (IMAP, Exchange, POP3, etc.) and allow you to react to new messages as they arrive, or shortly thereafter.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Lowell
Lowell
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27900 Visits: 39920
opc.three (1/2/2013)
xp_readmail is for SQL Mail, which is deprecated.

In my opinion this kind of work should be done way far away from the database engine. There are many applications out there that will monitor an inbox (IMAP, Exchange, POP3, etc.) and allow you to react to new messages as they arrive, or shortly thereafter.


i played around and created a CLR which reads the emails off of a POP3 server as a proof of concept; like every email application I've ever fiddled with, it can be slow. expecting results in 30 seconds just plain woun't happen unless you delete everything you pick up off of the server.

for example, when it picks up my personal email box, it finds out there are 407 available messages; because I added a parameter, and so when it downloaded the most recent x number of messages (54 messages in one example, 25 in another) , it took 47 seconds and 31 seconds respectively.

if it was still getting the whole 407 emails, i would recon it would take on the order of 400 to 600 seconds at least, assuming the mail server doesn't hiccup

Ok There's an advantage if you love TSQL since I have the results in a Table Value function so i could fiddle with the results from there...but it would require parsing the body and all sorts of other rules and stuff that hits on the point opc.three chimed in on...there's better tools that SQL to be doing this. it'd be a whole 'nuther level of headache trying to handle attachments, which are potentially one-to-many for each email message.

it's moderately difficult and took me a while to get the prototype to work, and I think i'll throw an article up for it, since it's an often-asked but rarely example kind of question. the caveats and problems

the body ends up like this in an nvarchar(max) field:

Hi Lowell,=0D=0A=0D=0AA new reply has been added by Steve Jones - SSC Editor= to a topic you're subscribed to.=0D=0A=0D=0AYou can view the reply by clicking= the link below...=0D=0A=0D=0Ahttp://www.sqlservercentral.com/Forums/FindPost1398664.aspx= =0D=0A=0D=0AYou can unsubscribe from topics at anytime from your control= or the following link...=0D=0A=0D=0Ahttp://www.sqlservercentral.com/Forums/TopicSubscriptions1.aspx= =0D=0A=0D=0AYou may need to manually copy & paste the URL into the address= bar of your browser if the text above is not linked. Please watch for the= URL wrapping onto 2 lines. =0D=0A=0D=0A-----------------------------------------= =0D=0A=0D=0ASQLServerCentral=0D=0Ahttp://www.sqlservercentral.com/Forums/= =0D=0A


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14803 Visits: 14396
Thanks, Lowell. SQLCLR is a powerful tool, to be sure. You know where I stand on the topic already but I am curious now, can the assembly you created be run as SAFE or does it need EXTERNAL_ACCESS or UNSAFE?

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Lowell
Lowell
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27900 Visits: 39920
opc.three (1/3/2013)
Thanks, Lowell. SQLCLR is a powerful tool, to be sure. You know where I stand on the topic already but I am curious now, can the assembly you created be run as SAFE or does it need EXTERNAL_ACCESS or UNSAFE?


it required UNSAFE mode , i believe due to the use of System.Net.Sockets and System.Runtime.InteropServices;


because it piqued my interest, i'm also now fiddling around with adding a CLR that does IMAP also, since that would allow you to find unread items, read specific Folders for new items, etc vs the whole inbox that POP3 limits me to.

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search