jsvb1977
asked on
How to specify the FROM Attribute when using SQL DB Mail
We insert records into a table from our website, and then use the sql db send mail to actually email the information out to it's recipients. We do this for tracking purposes.
Is it possible to specify the FROM attribute when sending the email to be an address OTHER than the email address specified in the SQL DB Send Email Profile?
If so, how can that be done? [we have created a field in the email table to hold the FROM email address]
Is it possible to specify the FROM attribute when sending the email to be an address OTHER than the email address specified in the SQL DB Send Email Profile?
If so, how can that be done? [we have created a field in the email table to hold the FROM email address]
BEGIN
SELECT
@EmailQueueID=EmailQueueID,
@EmailID=EmailID,
@AppID=AppID,
@MessageTypeID = MessageTypeID,
@EmailTo=EmailTo,
@EmailFrom=EmailFrom,
@EmailSubject=EmailSubject,
@EmailCC=EmailCC,
@EmailBCC=EmailBCC,
@EmailAttachment=EmailAttachment,
@EmailBody=EmailBody,
@CreateDate=CreateDate,
@SendDate=SendDate
FROM
#tmpEmailQueue
WHERE
EmailQueueID = @CurrentRow
--------------------------------------------------------------------------------
---- http://msdn.microsoft.com/en-us/library/ms190307(SQL.90).aspx
---- Call SQL DB Mail in MSDB Database using values of rows in email queue
--------------------------------------------------------------------------------
EXEC @ReturnCode = msdb..sp_send_dbmail
@profile_name = @EmailProfileName,
@recipients = @EmailTo,
@copy_recipients = @EmailCC,
@blind_copy_recipients = @EmailBCC,
@body = @EmailBody,
@body_format = 'HTML',
@subject = @EmailSubject;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Simplest method is setup another dbmail profile using the FROM address you want.
ASKER
Understood. Since the table we use has a field for 'FROM' -- [meaning, i can populate that field with any email address i want] I was wondering if it is possible to pass that value through the DB SEND Mail and use that as the FROM email address instead of the email address that is configured in the DB Mail Profile.
Does that make sense?
Or was your reply essentially saying that it is not possible?
Jason