Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003

    Unanswered: Using xp_readmail to read encrypted emails

    I am having problems reading the body of encrypted emails in the sql mail account of Microsoft SQL Server 2000. The passwords are configured within the account so that anyone with access to the account can open them without being prompted for a password. However, when I try to access them programmatically with SQL, I cannot retrieve the body of the email. I can retrieve the subject of the email, but not the body. With unencrypted emails I can retrieve everything.

    I am running a test script to return the subject of the email and the number of bytes in the body:

    declare @hMessage varchar(8000)
    declare @MessageText varchar(8000)
    declare @MessageSubject varchar(1000)
    declare @skip_bytes int
    declare @msg_length int

    EXEC master..xp_findnextmsg @msg_id=@hMessage OUT
    WHILE @hMessage IS NOT NULL
    set @skip_bytes = 0

    exec master..xp_readmail
    @msg_id = @hMessage,
    @message = @MessageText OUTPUT,
    @skip_bytes = @skip_bytes OUTPUT,
    @msg_length = @msg_length OUTPUT,
    @Subject = @MessageSubject OUTPUT

    print @MessageSubject
    print @skip_bytes
    print '*************************************'

    EXEC master..xp_findnextmsg @msg_id=@hMessage OUT

    The results I get are as follows:

    Subject #1
    Subject #2
    Subject #3
    Subject #4

    All of the results of "0" are from encrypted emails that definitely have information in the body of the email, but SQL is not able to get to the body and returns a value of 0 for the number of bytes in the body. The unencrypted emails return the number of bytes in the body without problem.

    Does anyone know what I have to do to programmatically read the body of an encrypted email with SQL?

  2. #2
    Join Date
    Aug 2002
    Not sure whether you can achieve this using SQL Server alone, may be required MS Exchange client or any other programs to do so. Refer to MS Site for any information.
    --Satya SKJ
    Microsoft SQL Server MVP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts