sp-send-dbmail

sp_send_dbmail attachment encoding

十年热恋 提交于 2019-12-04 14:43:02
I am using sp_send_dbmail in SQL2005 to send an email with the results in an attachment. When the attachment is sent it is UCS-2 Encoded, I want it to be ANSI or UTF-8. Here is the SQL EXEC msdb.dbo.sp_send_dbmail @recipients = 'temp@example.com' , @query = 'DECLARE @string_to_trim varchar(60);SET @string_to_trim = ''1234''; select rtrim(@string_to_trim), ''tom''' , @query_result_header=0 , @subject = 'see attach' , @body= 'temp body' , @profile_name= N'wksql01tAdmin' , @body_format = 'HTML' ,@query_result_separator = ',' ,@query_attachment_filename = 'results.csv' ,@query_no_truncate = '0' ,

SQL Server SP_SEND_DBMAIL Image file attachment

风格不统一 提交于 2019-12-04 08:22:09
I am using a trigger on a table to send an email using sp_send_dbmail. I want to include a file attachment in the email of an image type. The raw data for the jpeg is stored in the ndl_Image column which is of type binary. I have the following code:- DECLARE @ReferenceID varchar(max) DECLARE @Recipient varchar(Max) DECLARE @Body varchar(max) DECLARE @Subject varchar(max) DECLARE @Q varchar(max) --Get the EntryId and FormID for the inserted data. SET @ReferenceID = 40 SET @Recipient = (SELECT ndl_CategorySendTo FROM ndl_config WHERE ndl_CategoryName = 'Dead Animal') SET @Body = '<html>A new

Using sp_send_dbmail with recieptent and content from single sql row

走远了吗. 提交于 2019-12-04 04:58:07
问题 I have a table filled with oldUserID, newUserID, name and email. I want to use sp_send_dbmail to the email on each row. For example: oldUserID | newUserID | name | email 21213125 | 2355233571 | Tom | tom@gmail.com 65465465 | 4564884664 | Mat | mat@gmail.com And so on for 200 rows. Is there any way to send an sp_send_dbmail to the email on each row including oldUserID and newUserID? The output in the mail would be something like: "Your old user id: 21213125, your new user id: 2355233571" I

How to send mail from Stored Procedure?

淺唱寂寞╮ 提交于 2019-12-04 03:56:16
问题 I need to send a mail from Stored Procedure. I knew it is possible. I studied it from this link . How do i authenticat in SMTP Server. Do you have any idea.? Thanks 回答1: You can use SQL Database Mail. See Database Mail and SQL Mail Stored Procedures (Transact-SQL) And here's a Tutorial 回答2: Using extended stored procedures to create an use and ActiveX that sends the email or create an assembly that sends the mails and use it from sql2008. 来源: https://stackoverflow.com/questions/3177267/how-to

meaning of the values of sent_status on msdb.dbo.sysmail_mailitems

走远了吗. 提交于 2019-12-03 14:20:35
I am sending emails from SQL Server, and need to map the values of the sent_status column on the msdb.dbo.sysmail_mailitems table to something more descriptive. So far I have identified two values: 1 = 'Sent' 2 = 'Failed' Are there any more possible values, and if so what do they represent? sent_status, --0 new, not sent, 1 sent, 2 failure or 3 retry. On the MSDN page for the related msdb.dbo.sysmail_allitems table, the description for sent_status says: The status of the mail. Possible values are: sent - The mail was sent. unsent - Database mail is still attempting to send the message.

Sending Email in SQL Server 2008 R2

柔情痞子 提交于 2019-12-02 16:44:54
问题 I am tasked with a feature to send e-mail reminders to employees in my company if they haven't completed an attestation form via an intranet Web application. I was thinking of writing a stored procedure that gets called in a nightly database job (SQL Server 2008 R2). The proc would select employee e-mail address values and loop through them via cursor, so that for each e-mail found an e-mail is sent using msdb.dbo.sp_send_dbmail. The concern I have is that this is for a large company and tens

Sending Email in SQL Server 2008 R2

浪子不回头ぞ 提交于 2019-12-02 12:25:14
I am tasked with a feature to send e-mail reminders to employees in my company if they haven't completed an attestation form via an intranet Web application. I was thinking of writing a stored procedure that gets called in a nightly database job (SQL Server 2008 R2). The proc would select employee e-mail address values and loop through them via cursor, so that for each e-mail found an e-mail is sent using msdb.dbo.sp_send_dbmail. The concern I have is that this is for a large company and tens of thousands of e-mail could go out nightly. Is there a way to mitigate performance concerns when

Using sp_send_dbmail with recieptent and content from single sql row

China☆狼群 提交于 2019-12-02 05:26:54
I have a table filled with oldUserID, newUserID, name and email. I want to use sp_send_dbmail to the email on each row. For example: oldUserID | newUserID | name | email 21213125 | 2355233571 | Tom | tom@gmail.com 65465465 | 4564884664 | Mat | mat@gmail.com And so on for 200 rows. Is there any way to send an sp_send_dbmail to the email on each row including oldUserID and newUserID? The output in the mail would be something like: "Your old user id: 21213125, your new user id: 2355233571" I would appreciate not to enter each emailadress manually. Thank you! DECLARE @txt NVARCHAR(MAX) , @name

sp_send_dbmail attach files stored as varbinary in database

别等时光非礼了梦想. 提交于 2019-12-01 18:21:19
I have a two part question relating to sending query results as attachments using sp_send_dbmail. Problem 1: Only basic .txt files will open. Any other format like .pdf or .jpg are corrupted. Problem 2: When attempting to send multiple attachments, I receive one file with all file names glued together. I'm running SQL Server 2005 and I have a table storing uploaded documents: CREATE TABLE [dbo].[EmailAttachment]( [EmailAttachmentID] [int] IDENTITY(1,1) NOT NULL, [MassEmailID] [int] NULL, -- foreign key [FileData] [varbinary](max) NOT NULL, [FileName] [varchar](100) NOT NULL, [MimeType]

How can I use sp_send_dbmail to send multiple queries?

家住魔仙堡 提交于 2019-12-01 17:57:46
I'm trying to send an email using sp_send_dbmail . I need it to send one query as an attachment and another as part of the body of the email. The problem is that sp_send_dbmail only has one @query parameter, and I can't see any way to add another one. Is there any way to either a) add a second query (with all of the parameters attached to it) or b) execute the query into a variable and then add that to the body of my email? I'm using sql-server 2005. TIA! Use the @query parameter of the stored procedure msdb.dbo.sp_send_dbmail for the attachment and use the @body parameter with a variable that