sp_send_dbmail (The specified string is not in the form required for an e-mail address)

  • Hi!!

    When I'm trying to send mail alerts through a procedure, it is giving the error:

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 3 (2009-03-03T19:33:53). Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for an e-mail address.).

    But the recipient mail id is correct, and i can send them mail though outlook. Please help me to identify the probable reasons for this kind of error. Any configuration issue?? test mails from the profile used is working fine. HOw to solve??

  • Can you post the code you are using?

    Have you removed the mailing section of your procedure and tried it directly in SSMS?

  • declare @rgn varchar(3),

    @usr_cd varchar (5000),

    @usr_nm varchar (5000),

    @eml_id varchar (5000),

    @vc_mesgheading varchar(8000),

    @vc_message varchar(8000),

    @cntr_nm varchar(5000),

    @rcpnt_cc varchar(8000)

    select @rgn=rgn_cd from ccl_mst_cntr where cntr_cd=@srcicd and src_icd='zzzzz'

    set @rcpnt_cc = ''

    select @rcpnt_cc = @rcpnt_cc + ltrim(rtrim(a.email_id)) + '; '

    from mst_user a,mst_user_role_link b where a.src_icd=b.src_icd and a.usr_empl_cd=b.usr_empl_cd

    and b.role_cd='ROCSO'and a.actv='Y' and rgn_cd=@rgn

    and isnull(email_id,' ')<>' ' and isnull(email_id,'.')<>'.'

    --while exists(select 1 from #tempmail)

    --begin

    select top 1 @eml_id =email_id, @usr_nm=usr_empl_nm,@usr_cd=a.usr_empl_cd from mst_user a,mst_user_role_link b where a.src_icd=b.src_icd and a.usr_empl_cd=b.usr_empl_cd

    and b.role_cd='SAPMM'and a.actv='Y' and rgn_cd=@rgn

    and isnull(email_id,' ')<>' ' and isnull(email_id,'.')<>'.'

    select @cntr_nm=cntr_nm from ccl_mst_cntr where cntr_cd=@srcicd

    SELECT @vc_mesgheading = 'Dear '+ isnull( @usr_nm,'Friend')+',' + CHAR(13) + CHAR(13)

    SELECT @vc_message = @vc_mesgheading + CHAR(13) +@cntr_nm

    + '(Storage location - "'+ isnull(@strloc,' ') +'") has received material against ' + CHAR(13)+

    + 'SAP STO number : '+ isnull(@sto,' ') + ' and Delivery Challan No. '+ isnull(@DCcd,' ') +''+ CHAR(13)+

    + 'dated '+ convert(varchar,@DCdt,103) + ' which have been entered in ENCORE stock ledger through'+ CHAR(13)+

    + 'MRR No. ' + isnull(@MMR,' ') +'.'+' dated '+ convert(varchar,@MMRdt,103) +' .'+ CHAR(13)+CHAR(13)

    + 'Please enter Goods Receipt in SAP.'+ CHAR(13)+ CHAR(13)+

    'Regards, ' + CHAR(13) +

    'Admin '

    if((isnull(@eml_id,' ')<>' ') and (isnull(@rcpnt_cc,' ')<>' '))

    begin

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'Vistadb1',

    @recipients = @eml_id,

    @copy_recipients = @rcpnt_cc,

    @blind_copy_recipients = 'ronyroyr@xxx.com;mail2_rony@xxx.com;',

    @body = @vc_message,

    @subject = 'Received Details' ;

    end

  • Why don't you try a low-tech debugging aid

    print @eml_id

    print @rcpnt_cc

    Just prior to the exec for the mail send and see of the addresses are OK. You could even cut them out and paste then into your mail client to see what happens when you try and send them.

    If that provides no new leads then talk to your email admins and have them jump in with additional diagnostics message that are available to them that are provided by your SMTP server as well !

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

Viewing 4 posts - 1 through 3 (of 3 total)

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