Making xp_sendmail behave like Outlook

  • I want to utilize xp_sendmail in a db as much as possible. There are other ways to send mails like calls to CDONTS, but I'd prefer to stick with what I know. I am running SQL 2000 sp3, an Outlook 2k client on the sql server box and Exchange 2k.

    I want to...

    1) send mail to not only smtp addresses (xx@xxx.com) but to Outlook address book names and distribution lists

    2) make the sent mails appear in the Sent Items folder of the Outlook client on the sql server box.

    My only lead so far is the xp_sendmail's @type parameter, which BOL says...

    -------------------------------------------------------------------------

    [@type =] 'type'

    Is the input message type based on the MAPI mail definition:

    IP[M | C].Vendorname.subclass

    If type is NULL, message types beginning with IPM appear in the inbox of the mail client and are found or read by xp_findnextmsg. Message types beginning with IPC do not appear in the inbox of the mail client and must be found or read by setting the type parameter. The default is NULL.

    For more information about using custom message types, see the Microsoft Windows NT Resource Kit or the Microsoft Mail Technical Reference, available separately.

    ---------------------------------------------------------------------

    A couple of hours pouring through the above references has given any leads.

    Can anyone shed light on @type? Has anyone achieved 1) and 2) above?

  • Hi miked9999,

    quote:


    1) send mail to not only smtp addresses (xx@xxx.com) but to Outlook address book names and distribution lists

    2) make the sent mails appear in the Sent Items folder of the Outlook client on the sql server box.


    not sure if this will help you. but I think to make it appear in Sent items folder you will have to instanciate an Outlook or CDO object via sp_OACreate. And use some of these sp_OA... procedures in SQL Server.

    I guess there are several topic on this here on this site. For a deeper insight into CDO and its object model you might take a lok at http://www.cdolive.com.

    HTH

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Aargh, Frank think, before you post.

    Take a look at MSDN, should be all covered!

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Can you be more specific as to where on MSDN? And do you mean the CD's or the www?

  • Hi miked9999,

    sorry, a good starting point in MSDN is to look for IPM. From there you can jump to message class....According to MSDN IPM defines a message sent or received by humans while IPC classifies a message as sent or received by interprocess communication.

    quote:


    1) send mail to not only smtp addresses (xx@xxx.com) but to Outlook address book names and distribution lists


    They have also SMTP adresses. However, their adresses are resolved for better reading. For example, I could sent mails to Kalis, Frank (as appears in Outlook) or SMTP:frank.kalis@mydomain.de. Which is quite similar.

    quote:


    2) make the sent mails appear in the Sent Items folder of the Outlook client on the sql server box.


    Not quite sure how to achieve from within SQL Server, but should be found in MSDN under

    Platform SDK Documentation -> Messaging and Collaberation Services...

    HTH

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Well, MSDN has a few topics in IPM, but nothing that elaborates on this IPM.Vendorclass.subclass structure, so I'm none the wiser as to how to use it in TSQL.

    I'll probably take your suggestion about using sp_OA stored procedures & instantiating CDO objects.

  • One question on CDO and CDONTS - from what I see it has no built in facility to return queries in the message body, in the same way xp_mail does. Correct?

    If so it may prove less work to stick with xp_sendmail.

  • That'll teach me to check things before posting ! 🙂 xp_sendmail quite happily sends to non-smtp addresses like address book names and distribution lists, so no problems there. It just returns an error if its not an address book name AND is not a valid smtp, eg mwd @czz.com.au, with a space.

    So CDONTS or xp_semdmail? Well xp_sendmail can send queries and use your MAPI client's own address book, while CDONTS can send HTML, so take your pick I suppose. But then I beleive you can write html code into the body of your message, so xp_sendmail seems like the preferred option.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply