Showing posts with label portion. Show all posts
Showing posts with label portion. Show all posts

Wednesday, March 7, 2012

Change "from" portion of the email when calling sp_send_dbmail?

I want to be able to call sp_send_dbmail and be able to change the "from" portion of the email (the email and the display name) programmatically/data-driven as a sproc constructs and sends the email.

Is this possible?
I believe the only way to do this is to use different profiles|||Take a look at xp_smtp_sendmail http://www.sqldev.net/xp/xpsmtp.htm.|||To enhance Euan's reply refer to - http://www.sql-server-performance.com/da_email_functionality.asp & http://www.sqlservercentral.com/columnists/cBunch/introtodatabasemailinsql2005.asp links.|||

Your answer is not very practical when you have hundreds of users.

In the older SQL Server 2000 we used

Code Snippet

exec @.rc = master.dbo.xp_smtp_sendmail

@.FROM = @.in_FROM_ADDRESS,

@.FROM_NAME = @.in_FROM_NAME,

@.TO = @.in_TO_ADDRESS,

@.CC = @.in_CC,

@.BCC = @.in_BCC,

@.priority = @.in_priority,

@.subject = @.in_subject,

@.type = @.in_type,

@.message = @.in_message

Which had the first paramater @.From and the second one was @.From_Name.

Both of which are now gone in the new send dbmail

Code Snippet

exec @.rc = msdb.dbo.sp_send_dbmail

@.profile_name = 'MIS',

@.recipients = @.in_TO_ADDRESS,

@.copy_recipients = @.in_CC,

@.blind_copy_recipients = @.in_BCC,

@.importance = @.in_priority,

@.subject = @.in_subject,

@.body = @.in_message

The resulting emails are coming from whatever you set the Profile name to be. As you would by default set the profile to be generic, something like 'MIS Server Mailer' or whatever your application name is. Hense all the mails now come from this generic user.

This is a problem, and MS should extend the DB Mail to include this rather simple option.

Change "from" portion of the email when calling sp_send_dbmail?

I want to be able to call sp_send_dbmail and be able to change the "from" portion of the email (the email and the display name) programmatically/data-driven as a sproc constructs and sends the email.

Is this possible?
I believe the only way to do this is to use different profiles|||Take a look at xp_smtp_sendmail http://www.sqldev.net/xp/xpsmtp.htm.|||To enhance Euan's reply refer to - http://www.sql-server-performance.com/da_email_functionality.asp & http://www.sqlservercentral.com/columnists/cBunch/introtodatabasemailinsql2005.asp links.|||

Your answer is not very practical when you have hundreds of users.

In the older SQL Server 2000 we used

Code Snippet

exec @.rc = master.dbo.xp_smtp_sendmail

@.FROM = @.in_FROM_ADDRESS,

@.FROM_NAME = @.in_FROM_NAME,

@.TO = @.in_TO_ADDRESS,

@.CC = @.in_CC,

@.BCC = @.in_BCC,

@.priority = @.in_priority,

@.subject = @.in_subject,

@.type = @.in_type,

@.message = @.in_message

Which had the first paramater @.From and the second one was @.From_Name.

Both of which are now gone in the new send dbmail

Code Snippet

exec @.rc = msdb.dbo.sp_send_dbmail

@.profile_name = 'MIS',

@.recipients = @.in_TO_ADDRESS,

@.copy_recipients = @.in_CC,

@.blind_copy_recipients = @.in_BCC,

@.importance = @.in_priority,

@.subject = @.in_subject,

@.body = @.in_message

The resulting emails are coming from whatever you set the Profile name to be. As you would by default set the profile to be generic, something like 'MIS Server Mailer' or whatever your application name is. Hense all the mails now come from this generic user.

This is a problem, and MS should extend the DB Mail to include this rather simple option.

Friday, February 10, 2012

Cast DateTime To Date?

I have a datetime field in a database, but want to query on the date
portion only.
1. Can someone provide an example?
2. Any good online SQL resources specific to MSSQL dialect?
Thank you,
--
Warm Regards,
Lee
"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."1. Can someone provide an example?
Sure, SELECT CONVERT(VARCHAR(10),GETDATE(),112) --Look in the BOL for
more information about Convert.
2. Any good online SQL resources specific to MSSQL dialect?
Sure, look in the BOL for more information: http://www.aspfaq.com/2229
HTH, jens Suessmeyer.|||Datetime to Date =>
This will work,
SELECT getdate()
SELECT CAST(FLOOR(CAST( getdate() AS float)) AS DATETIME)
For MSSQL dialect, look BOL
Thanks,
Sree
"Lee" wrote:
>
> I have a datetime field in a database, but want to query on the date
> portion only.
> 1. Can someone provide an example?
> 2. Any good online SQL resources specific to MSSQL dialect?
> Thank you,
> --
> Warm Regards,
> Lee
> "Upon further investigation it appears that your software is missing
> just one thing. It definitely needs more cow bell..."
>