Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Kosmo114
Starting Member
1 Post |
Posted - 2009-09-24 : 05:33:13
|
Is there a way in database mail to use a single profile, but declare the email senders address in the proceedure that fetches the email message from my table. I have an email relay I use to send outbound emails from multiple domains, and I house the from name, and from email in my email table. I want to avoid setting up multiple email profiles in sql server 2005.Below is my proceedure fetching emails prior to sending. I was hoping someone might have done something similar and can offer a sugestion.DECLARE @ID as INTDECLARE @Mailto as varchar(5000)DECLARE @Subject as varchar(5000)DECLARE @Body as varchar(8000)DECLARE @CC as varchar(5000)DECLARE @Bcc as varchar(5000)DECLARE EmailCursor CURSOR FOR SELECT ID, Mailto, Subject, Body, CC, Bcc FROM MailingListWHERE status is NULL or status = 0 OPEN EmailCursor FETCH NEXT FROM EmailCursor INTO @ID, @Mailto, @Subject, @Body, @CC, @BccWHILE @@FETCH_STATUS = 0 and @@Error = 0BEGIN exec msdb..sp_send_dbmail @profile_name = 'Outboundemail',@recipients = @Mailto,@copy_recipients = @CC,@blind_copy_recipients = @Bcc,@subject = @Subject,@body = @Body |
|
|
|
|
|
|