|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562,
Visits: 3,451
|
|
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---------- While 1 = 1 (Learning SQL....) Click to get fast response of your post
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 6:43 AM
Points: 1,785,
Visits: 1,008
|
|
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
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 9:27 PM
Points: 6,695,
Visits: 11,711
|
|
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
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 11,605,
Visits: 27,645
|
|
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
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 9:27 PM
Points: 6,695,
Visits: 11,711
|
|
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
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 1:11 PM
Points: 11,605,
Visits: 27,645
|
|
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
--There is no spoon, and there's no default ORDER BY in sql server either. Actually, Common Sense is so rare, it should be considered a Superpower. --my son
|
|
|
|