MadeiraData / sql-clr-ics

Send Calendar Event / Appointment Invitations (iCal formatted file) from within SQL Server using a CLR stored procedure
https://git.madeiradata.com/sql-clr-ics/
MIT License
9 stars 1 forks source link

System.Exception: Error sending mail #17

Closed Julien22bzh closed 4 years ago

Julien22bzh commented 4 years ago

Hi Eitan,

thanks for your job. I try your script but i have a problem to send email. I have this message :

Msg 6522, Niveau 16, État 1, Procédure clr_send_ics_invite, Ligne 0 [Ligne de départ du lot 0] Une erreur .NET Framework s'est produite au cours de l'exécution de la routine ou de la fonction d'agrégation définie par l'utilisateur "clr_send_ics_invite" : System.Exception: Error sending mail: Échec d'envoi du courrier. System.Exception: à StoredProcedures.clr_send_ics_invite(SqlString profile_name, SqlString recipients, SqlString copy_recipients, SqlString blind_copy_recipients, SqlString from_address, SqlString reply_to, SqlString subject, SqlString body, SqlString body_format, SqlString importance, SqlString sensitivity, SqlString file_attachments, SqlString location, SqlDateTime start_time_utc, SqlDateTime end_time_utc, SqlDateTime timestamp_utc, SqlString method, SqlInt32 sequence, SqlString prod_id, SqlBoolean use_reminder, SqlInt32 reminder_minutes, SqlBoolean require_rsvp, SqlString recipients_role, SqlString copy_recipients_role, SqlString blind_copy_recipients_role, SqlString smtp_servername, SqlInt32 port, SqlBoolean enable_ssl, SqlBoolean use_default_credentials, SqlString username, SqlString password, SqlBoolean suppress_info_messages, SqlString& event_identifier, SqlString& ics_contents) .

I use this query : DECLARE @EventID nvarchar(255)

EXEC sp_send_calendar_event @from_address = N'xxxxxxxxxx@xxxxxxxxxx', @recipients = N'xxxxxxxxxx@xxxxxxxxxx', @subject = N'let us meet for pizza!', @body = N'Bring your own beer', @body_format = N'HTML', @location = N'The Pizza place at Hank and Errison corner', @start_time_utc = '2019-07-02 19:00', @end_time_utc = '2019-07-02 23:00', @timestamp_utc = '', @smtp_servername = 'X.X.X.X', @port = 25, @enable_ssl = 0, @username = N'xxxxxxxxxx@xxxxxxxxxx', @password = N'xxxxxxxxxxxxxxxxxxx', @use_reminder = 1, @reminder_minutes = 300, @require_rsvp = 0, --@method = 'CANCEL', @event_identifier = @EventID OUTPUT

SELECT EventID = @EventID

I test SMTP server and it's ok.

Can you help me please ?

Julien

EitanBlumin commented 4 years ago

Hi Julien,

Based on the error, there seems to be an issue while sending the e-mail to the SMTP server. Please make sure that all the SMTP settings you provided are correct (username, password, SSL, port, server name), and also that the sender address is an address that's allowed as a sender in your SMTP server.

You could try using DBMail at your SQL Server to test the same SMTP settings and see if it works from there.

Also, I believe that setting the @timestamp_utc parameter to an empty string could possibly cause an issue:

@timestamp_utc = '',

Please either set it to NULL, or don't set it at all.

Julien22bzh commented 4 years ago

Hi Eitan,

Thanks for your response. I test a another SMTP software (JBMail plus 3.3) on the same server with same settings and email sent successfully.

After i tried with

@timestamp_utc = NULL,

but result is NOK,

Julien

EitanBlumin commented 4 years ago

I see. Unfortunately, the error message you got is not enough to properly troubleshoot the issue.

I just published a new release with improved error handling. Hopefully, you'll be able to see the actual underlying issue.

Please try this one: https://github.com/MadeiraData/sql-clr-ics/releases/tag/v2.2-beta

Julien22bzh commented 4 years ago

Eitan,

It's ok with new release. I obtain an EventID and i receive a calendar invitation without RSVP requirement.

Thanks for all. Julien

EitanBlumin commented 4 years ago

I see. Must've been an issue with the older version, then.

I'm glad it worked out!