Code Monkey home page Code Monkey logo

sql-clr-ics's Introduction

sp_send_calendar_event

Send Calendar Event / Appointment Invitations (iCal formatted file) from within SQL Server using a CLR stored procedure.

In this page:

Background

Click here for some background information about this project.

Prerequisites

The CLR assembly in this project can only be deployed to a SQL Server with CLR enabled, and support for UNSAFE permission set.

Installation

If you have SSDT, you can open the SQL server project and publish it to your database of choice. Alternatively, you can use this simple installation script that sets everything up for you in your database of choice.

Syntax

exec sp_send_calendar_event
	[   [ @profile_name = ] 'profile_name' ]
	[ , [ @recipients = ] 'recipients [ ; ...n ]' ]
	[ , [ @copy_recipients = ] 'copy_recipients [ ; ...n ]' ]
	[ , [ @blind_copy_recipients = ] 'blind_copy_recipients [ ; ...n ]' ]
	[ , [ @from_address = ] 'from_address' ]
	[ , [ @reply_to = ] 'reply_to' ]
	[ , [ @subject = ] 'subject' ]
	[ , [ @body = ] 'body' ]
	[ , [ @body_format = ] 'TEXT | HTML' ]
	[ , [ @importance = ] 'Low | Normal | High' ]
	[ , [ @sensitivity = ] 'PUBLIC | PRIVATE | CONFIDENTIAL' ]
	[ , [ @file_attachments = ] 'file_attachments [ ; ...n ]' ]
	[ , [ @location = ] 'location' ]
	[ , [ @start_time_utc = ] 'start_time_utc' ]
	[ , [ @end_time_utc = ] 'end_time_utc' ]
	[ , [ @timestamp_utc = ] 'timestamp_utc' ]
	[ , [ @method = ] 'PUBLISH | REQUEST | REPLY | CANCEL | ADD | REFRESH | COUNTER | DECLINECOUNTER' ]
	[ , [ @sequence = ] sequence ]
	[ , [ @prod_id = ] 'prod_id' ]
	[ , [ @use_reminder = ] 1 | 0 ]
	[ , [ @reminder_minutes = ] reminder_minutes ]
	[ , [ @require_rsvp = ] 1 | 0 ]
	[ , [ @recipients_role = ] 'REQ-PARTICIPANT | OPT-PARTICIPANT | NON-PARTICIPANT | CHAIR' ]
	[ , [ @copy_recipients_role = ] 'REQ-PARTICIPANT | OPT-PARTICIPANT | NON-PARTICIPANT | CHAIR' ]
	[ , [ @blind_copy_recipients_role = ] 'REQ-PARTICIPANT | OPT-PARTICIPANT | NON-PARTICIPANT | CHAIR' ]
	[ , [ @smtp_servername = ] 'smtp_servername' ]
	[ , [ @port = ] port ]
	[ , [ @enable_ssl = ] 1 | 0 ]
        [ , [ @use_default_credentials = ] 1 | 0 ]
	[ , [ @username = ] 'username' ]
	[ , [ @password = ] 'password' ]
	[ , [ @suppress_info_messages = ] 1 | 0 ]
	[ , [ @event_identifier = ] 'event_identifier' [ OUTPUT ] ]
	[ , [ @ics_contents = ] 'ics_contents' [ OUTPUT ] ]

Arguments

[ @profile_name = ] 'profile_name'

Is the name of the profile to send the message from. The profile_name is of type sysname, with a default of NULL. The profile_name must be the name of an existing Database Mail profile. When no profile_name is specified, sp_send_calendar_event checks whether @from_address was specified. If not, it uses the default public profile for the msdb database. If @from_address wasn't specified, and there is no default public profile for the database, @profile_name must be specified.

[ @recipients = ] 'recipients [ ; ...n ]'

Is a semicolon-delimited list of e-mail addresses to send the message to. The recipients list is of type nvarchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_calendar_event returns an error. This parameter maps to the ATTENDEE property of the iCal spec.

[ @copy_recipients = ] 'copy_recipients [ ; ...n ]'

Is a semicolon-delimited list of e-mail addresses to carbon copy the message to. The copy recipients list is of type nvarchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_calendar_event returns an error. This parameter maps to the ATTENDEE property of the iCal spec.

[ @blind_copy_recipients = ] 'blind_copy_recipients [ ; ...n ]'

Is a semicolon-delimited list of e-mail addresses to blind carbon copy the message to. The blind copy recipients list is of type nvarchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_calendar_event returns an error. This parameter maps to the ATTENDEE property of the iCal spec.

[ @from_address = ] 'from_address'

Is the value of the 'from address' of the email message, and the organizer of the calendar meeting. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type nvarchar(max). If no parameter is specified, the default is NULL. This parameter maps to the ORGANIZER property of the iCal spec.

[ @reply_to = ] 'reply_to'

Is the value of the 'reply to address' of the email message. It accepts only one email address as a valid value. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type nvarchar(max). If no parameter is specified, the default is NULL.

[ @subject = ] 'subject'

Is the subject of the e-mail message. The subject is of type nvarchar(255). If no subject is specified, the default is 'SQL Server Meeting'. This parameter maps to the SUMMARY property of the iCal spec.

[ @body = ] 'body'

Is the body of the e-mail message. The message body is of type nvarchar(max), with a default of NULL. This parameter maps to the DESCRIPTION property of the iCal spec.

[ @body_format = ] 'TEXT | HTML'

Is the format of the message body. The parameter is of type varchar(20). When specified, the headers of the outgoing message are set to indicate that the message body has the specified format. The parameter may contain one of the following values:

  • TEXT
  • HTML

Defaults to TEXT.

[ @importance = ] 'LOW | NORMAL | HIGH'

Is the importance of the message. The parameter is of type varchar(6). The parameter may contain one of the following values:

  • Low
  • Normal
  • High

Defaults to Normal.

The parameter is implemented using the System.Net.Mail.MailPriority enum, and maps to the PRIORITY property of the iCal spec, based on a CUA with a three-level priority scheme.

[ @sensitivity = ] 'PUBLIC | PRIVATE | CONFIDENTIAL'

Is the sensitivity classification of the message. The parameter is of type nvarchar(12). The parameter may contain one of the following values, as per the CLASS property of the iCal spec:

  • Public
  • Private
  • Confidential

Defaults to Public.

[ @file_attachments = ] 'file_attachments [ ; ...n ]'

Is a semicolon-delimited list of file names to attach to the e-mail message. Files in the list must be specified as absolute paths. The attachments list is of type nvarchar(max). By default, Database Mail limits file attachments to 1 MB per file.

[ @location = ] 'location'

Is the location of the calendar meeting. The parameter is of type nvarchar(255), with a default of NULL. The parameter maps to the LOCATION property of the iCal spec.

[ @start_time_utc = ] 'start_time_utc'

Is the start time of the calendar meeting, in UTC. The parameter is of type datetime. If the parameter is not specified, it defaults to @timestamp_utc + 5 hours. The parameter maps to the DTSTART property of the iCal spec

[ @end_time_utc = ] 'end_time_utc'

Is the end time of the calendar meeting, in UTC. The parameter is of type datetime. If the parameter is not specified, it defaults to @start_time_utc + 1 hour. The parameter maps to the DTEND property of the iCal spec.

[ @timestamp_utc = ] 'timestamp_utc'

Is the date and time when the calendar event was created, in UTC. The parameter is of type datetime. If the parameter is not specified, it defaults to current UTC time. The parameter maps to the DTSTAMP property of the iCal spec.

[ @method = ] 'PUBLISH | REQUEST | REPLY | CANCEL | ADD | REFRESH | COUNTER | DECLINECOUNTER'

Is the method of the calendar event message. The parameter is of type nvarchar(14). The parameter may contain one of the following values, as per the METHOD property of the iCalendar Transport-independent Interoperability Protocol (iTIP):

  • PUBLISH
  • REQUEST
  • REPLY
  • CANCEL
  • ADD
  • REFRESH
  • COUNTER
  • DECLINECOUNTER

Defaults to REQUEST.

[ @sequence = ] sequence

Is the sequence of the calendar event message. The parameter is of type int, with a default of 0. Unless @method is specified as 'CANCEL', in which case the default would be 1. Proper usage of this parameter is important when updating existing calendar events, since each consecutive update must have a higher sequence number than the one before it. This parameter maps to the SEQUENCE property of the iCal spec.

[ @prod_id = ] 'prod_id'

Is the PRODID property of the calendar meeting. The parameter is of type nvarchar(255), with a default of 'Schedule a Meeting'. This parameter maps to the PRODID property of the iCal spec.

[ @use_reminder = ] 1 | 0

Determines whether to add a reminder to the event. The parameter is of type bit, with a default of 1 (true), which adds a VALARM component to the iCal document.

[ @reminder_minutes = ] reminder_minutes

Is the number of minutes to set for the event reminder. The parameter is of type int, with a default of 15. The parameter maps to the TRIGGER property of the iCal spec.

[ @require_rsvp = ] 1 | 0

Determines whether participants are required to respond with an RSVP. The parameter is of type bit, with a default of 0 (false). If this parameter equals to 0 (false), then all participants are assumed to have accepted their invitation, without requesting a response. The parameter maps to the PARTSTAT and RSVP properties of the iCal spec.

[ @recipients_role = ] 'REQ-PARTICIPANT | OPT-PARTICIPANT | NON-PARTICIPANT | CHAIR'

Is the meeting role for the participants specified in the @recipients parameter. The parameter is of type nvarchar(15). The parameter may contain one of the following values, as per the ROLE property of the iCal spec:

  • REQ-PARTICIPANT
  • OPT-PARTICIPANT
  • NON-PARTICIPANT
  • CHAIR

Defaults to REQ-PARTICIPANT.

[ @copy_recipients_role = ] 'REQ-PARTICIPANT | OPT-PARTICIPANT | NON-PARTICIPANT | CHAIR'

Is the meeting role for the participants specified in the @copy_recipients parameter. The parameter is of type nvarchar(15). The parameter may contain one of the following values, as per the ROLE property of the iCal spec:

  • REQ-PARTICIPANT
  • OPT-PARTICIPANT
  • NON-PARTICIPANT
  • CHAIR

Defaults to OPT-PARTICIPANT.

[ @blind_copy_recipients_role = ] 'REQ-PARTICIPANT | OPT-PARTICIPANT | NON-PARTICIPANT | CHAIR'

Is the meeting role for the participants specified in the @blind_copy_recipients parameter. The parameter is of type nvarchar(15). The parameter may contain one of the following values, as per the ROLE property of the iCal spec:

  • REQ-PARTICIPANT
  • OPT-PARTICIPANT
  • NON-PARTICIPANT
  • CHAIR

Defaults to NON-PARTICIPANT.

[ @smtp_servername = ] 'smtp_servername'

Is the SMTP server name to be used for sending the e-mail message. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type nvarchar(255). If no parameter is specified, and no mail profile was used, the default is 'localhost'.

[ @port = ] port

Is the SMTP server port to be used for sending the e-mail message. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type int. If no parameter is specified, and no mail profile was used, the default is 25.

[ @enable_ssl = ] 1 | 0

Determines whether the SMTP server should use SSL authentication. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type bit. If no parameter is specified, and no mail profile was used, the default is 0 (false).

[ @use_default_credentials = ] 1 | 0

Determines whether the SMTP server should use its default network credentials. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type bit. If no parameter is specified, and no mail profile was used, the default is 0 (false). If @username is specified, this parameter is ignored.

[ @username = ] 'username'

Is the userame to be used when authenticating with the SMTP server. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type nvarchar(255). If no parameter is specified, and no mail profile was used, the default is to use the server's default network credentials instead.

[ @password = ] 'password'

Is the password to be used when authenticating with the SMTP server. This is an optional parameter used to override the settings in the mail profile (or if no mail profile was specified). This parameter is of type nvarchar(255). If no parameter is specified, the default is to use an empty string for the password.

NOTE: Unfortunately, since MSDB doesn't allow access to the mail profile passwords, it's impossible to utilize an existing mail profile for getting the password for an SMTP server. Therefore, unless you want to use an empty password or default network credentials, you must specify a value for this parameter.

[ @suppress_info_messages = ] 1 | 0

Determines whether to NOT display the success message after sending the e-mail. The parameter is of type bit, with a default of 0 (false).

[ @event_identifier = ] 'event_identifier' [ OUTPUT ]

Optional output parameter returns the event_identifier of the calendar meeting. You may also override this value by specifying a parameter with a non-null value for it, in order to uniquely identify a calendar event. If no event_identifier was specified, a Global Unique Identifier (Guid) will automatically be generated instead. This parameter must be specified when @method is 'CANCEL'. The event_identifier is of type nvarchar(255), and maps to the UID property of the iCal spec.

[ @ics_contents = ] 'ics_contents' [ OUTPUT ]

Optional output parameter returns the entire ICS attachment contents, as per the iCal standard specifications for a VCALENDAR document with a VEVENT calendar component. The parameter is of type nvarchar(max), with a default of NULL. This value is constructed dynamically based on the previous parameters that you can specify. However, you may also override this value by specifying a parameter with a non-null value for it, in order to completely ignore all the iCal-related parameters of the procedure, and try to send your own custom-made ICS attachment file. This means that you can construct your own VCALENDAR document, and try to implement various advanced functionalities not natively covered by sp_send_calendar_event, or even send a calendar component other than VEVENT, such as VTODO or VJOURNAL.

Result Sets

On success, returns the message "Mail Sent. Event Identifier: %s" (where %s is replaced with the sent @event_identifier), unless @suppress_info_messages is specified as 1 (true).

On Failure, returns an error message specifying the problem.

Remarks

I did my best to align the parameters of this procedure with Microsoft's sp_send_dbmail procedure. However, since this is a CLR procedure, there are limitations to what can be done. Specifically, it's impossible to define default values for parameters of type nvarchar(max) and varchar(max), and so I had to create a wrapper procedure in T-SQL instead.

Even though I tried to utilize Microsoft's Database Mail Profile mechanics, I couldn't get access to the account passwords (which is probably a good thing), and so the @password parameter becomes mandatory (unless you want to use an empty password or the server's default network credentials).

I also didn't implement any functionality involving multiple accounts per profile to be used as "failover" accounts. So only the first account per profile is used.

Examples

A. Send a calendar invitation with RSVP requirement

DECLARE @EventID nvarchar(255)
 
EXEC sp_send_calendar_event
        @from_address = N'[email protected]',
        @recipients = N'[email protected],[email protected]',
        @subject = N'let us meet for pizza!',
        @body = N'<h1>Pizza!</h1><p>Bring your own beer!</p>',
        @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 = '2019-03-30 18:00',
        @smtp_servername = 'smtp.gmail.com',
        @port = 465,
        @enable_ssl = 1,
        @username = N'[email protected]',
        @password = N'NotActuallyMyPassword',
        @use_reminder = 1,
        @reminder_minutes = 30,
        @require_rsvp = 1,
        @event_identifier = @EventID OUTPUT
 
SELECT EventID = @EventID

B. Cancel the previously sent invitation

EXEC sp_send_calendar_event
        @from_address = N'[email protected]',
        @recipients = N'[email protected],[email protected]',
        @subject = N'let us meet for pizza!',
        @body = N'<h1>Pizza!</h1><p>Bring your own beer!</p>',
        @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 = '2019-03-30 18:00',
        @smtp_servername = 'smtp.gmail.com',
        @port = 465,
        @enable_ssl = 1,
        @username = N'[email protected]',
        @password = N'NotActuallyMyPassword',
        @require_rsvp = 1,
        @method = 'CANCEL',
        @event_identifier = @EventID OUTPUT
 
SELECT EventID = @EventID

C. Send an automated calendar invitation without RSVP requirement (i.e. participants are auto-accepted)

DECLARE @EventID nvarchar(255)
 
EXEC sp_send_calendar_event
        @from_address = N'[email protected]',
        @recipients = N'[email protected],[email protected]',
        @subject = N'Weekly SLA Shift',
        @body = N'<h1>You are on-call this week!</h1><p>This is an automated message</p>',
        @body_format = N'HTML',
        @location = N'Our offices',
        @start_time_utc = '2019-07-01 00:00',
        @end_time_utc = '2019-07-04 23:59',
        @timestamp_utc = '2019-05-01 00:00',
        @smtp_servername = 'smtp.company.com',
        @port = 587,
        @enable_ssl = 1,
        @username = N'[email protected]',
        @password = N'SomethingPassword',
        @use_reminder = 1,
        @reminder_minutes = 300,
        @require_rsvp = 0,
        @event_identifier = @EventID OUTPUT
 
SELECT EventID = @EventID

License and copyright

This project is copyrighted by Eitan Blumin, and licensed under the MIT license agreement.

More info in the license file.

Acknowledgements

This project was based mostly on the following stack overflow discussion: Send email to Outlook with ics meeting appointment

Also used the RFC 2445 iCalendar specification as reference for further improvements and fine-tuning.

See Also

sql-clr-ics's People

Contributors

eitanblumin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

andtron

sql-clr-ics's Issues

Update the stand-alone installation script

Need to update the stand-alone script to reflect the changes in the assembly's binary code, as well as the changes made in respect to signing (as a replacement for the TRUSTWORTHY setting)

Add more code examples

Add more use cases under "Examples" (each one would need to be tested and verified first):

  • Update existing event using various method types: REQUEST, ADD, REFRESH...
  • Send HTML body using images uploaded with file_attachments
  • Send TEXT body
  • Example using SendGrid SMTP settings
  • An example using default credentials
  • Using profile_name to auto-complete SMTP settings
  • Using ics_contents to send custom VCALENDAR document

Event cancellation doesn't work right

When cancelling an event, I get in Outlook 365 a "not supported calendar message.ics" attachment, which cannot be opened in order to remove the event from the calendar.

Refactor parameters to mirror those of sp_send_dbmail

Need to add missing parameters such as @importance and @sensitivity.

Obviously not all parameters are relevant, and there would be extra parameters beyond those in sp_send_dbmail, but those that are common to both procedures, should be aligned properly.

Also, the order of the parameters must be such so that all mandatory parameters would be in the beginning (right now @subject is mandatory but it's placed after non-mandatory parameters. So either move it to the beginning, or make it non-mandatory as well).

sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]  
    [ , [ @recipients = ] 'recipients [ ; ...n ]' ]  
    [ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]  
    [ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]  
    [ , [ @from_address = ] 'from_address' ]  
    [ , [ @reply_to = ] 'reply_to' ]   
    [ , [ @subject = ] 'subject' ]   
    [ , [ @body = ] 'body' ]   
    [ , [ @body_format = ] 'body_format' ]  
    [ , [ @importance = ] 'importance' ]  
    [ , [ @sensitivity = ] 'sensitivity' ]  
    [ , [ @file_attachments = ] 'attachment [ ; ...n ]' ]  
    [ , [ @query = ] 'query' ]  
    [ , [ @execute_query_database = ] 'execute_query_database' ]  
    [ , [ @attach_query_result_as_file = ] attach_query_result_as_file ]  
    [ , [ @query_attachment_filename = ] query_attachment_filename ]  
    [ , [ @query_result_header = ] query_result_header ]  
    [ , [ @query_result_width = ] query_result_width ]  
    [ , [ @query_result_separator = ] 'query_result_separator' ]  
    [ , [ @exclude_query_output = ] exclude_query_output ]  
    [ , [ @append_query_error = ] append_query_error ]  
    [ , [ @query_no_truncate = ] query_no_truncate ]   
    [ , [ @query_result_no_padding = ] @query_result_no_padding ]   
    [ , [ @mailitem_id = ] mailitem_id ] [ OUTPUT ]

QA tests for v2.0

The following scenarios (at the least) must be tested and validated before publishing v2.0:

  • Using profile_name parameter for auto-completion of SMTP settings
  • Send recipients, copy_recipients and blind_copy_recipients with varying roles.
  • Check what happens when a NULL is sent for from_address (with + without SMTP profile).
  • Test multi-line text in free-text properties: subject, body, location, prod_id, event_identifier.
  • Test custom VCALENDAR instance using ics_contents parameter.
  • Try to send malicious code using the ics_contents parameter.

How to cancel or modify the invitation ?

Hi Eitan,
how are you ?

I want to cancel or modify the invitation. But I can't do it.
How do I send the EvenID parameter in the cancel or modify request ? there is no parameter for this.

Thanks,
Julien.

Better support for updating existing calendar events

As of right now, if you want to update an event, you must cancel it and create a new one.

Support for updating of existing events will require more sophisticated implementation in regards to the UID and SEQUENCE properties of the iCal spec.

System.InvalidOperationException: Invalid attempt to read when no data is present.

Msg 6522, Level 16, State 1, Procedure dbo.clr_send_ics_invite, Line 0 [Batch Start Line 78]
A .NET Framework error occurred during execution of user-defined routine or aggregate "clr_send_ics_invite":
System.InvalidOperationException: Invalid attempt to read when no data is present.
System.InvalidOperationException:
at System.Data.SqlClient.SqlDataReaderSmi.EnsureOnRow(String operationName)
at System.Data.SqlClient.SqlDataReaderSmi.GetSqlString(Int32 ordinal)
at 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)

Seeking to reopen #15

#15
Having this same issue with version 2.0 of this project any news about how to fix this issue?

System.Exception: Error sending mail

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

SQL Server 2008R2 deployment ?

Hi Eitan,

now i try to deploy sql-clr-ics on SQL Server 2008 R2 (with framework v2.0.50727), but i have error n°6257.

Creating Assembly [dbo].[sql_clr_ics]...
Msg 6257, Niveau 16, État 1, Ligne 1
Échec de CREATE ASSEMBLY pour l'assembly 'sql_clr_ics' car ce dernier a été créé pour une version du CLR (Common Language Runtime) qui n'est pas prise en charge.
** Une erreur a été rencontrée lors de l'exécution du lot. Abandon en cours.

Is it possible to deploy your solution on SQL Server 2008 ?
Can you help me to deploy solution on this server ?

Thanks,

Julien.

HTML and attachments interoperability

Originally posted by @vhu408 in #10 (comment)

Hi Eitan,

Thanks for your work. Wonder if you can comment on the below and if there's something I'm doing wrong.

1.) I 've found that if I use an HTML body email
e.g..

declare @html nvarchar(max)='<html> ..<table>...</table> </html>'
exec sp_send_calendar_event
...
@body=@html
...
GO

The result is an email msg not an event with an attached .ics file for the event (shows in the email as "not supported calendar message.ics") when the HTML is more "complex".. perhaps something to do with formatting(.. don't know.)

2.) I've found that if I use an HTML body that makes use of a CID image (and thus the image is attached..)
E.g..

declare @html nvarchar(max)='<html> ..... </html>'
exec sp_send_calendar_event
...
@body=@html,
@file_attachments = 'd:\dir1\picture.png'
...
GO

The result is merely an email msg, even the .ics attachment is missing.

It seems like an event is not created when the HTML is more "complex" or an attachment of any kind if included. And even with the emails (not events), the .ics file is sometime present and sometimes depending on if an attachment is included.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.