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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Need help of showing inline message

Author  Topic 

serenethy
Starting Member

2 Posts

Posted - 2006-01-25 : 10:25:26
Hi,i really need help from someone out there!Is Urgent! I am currently working on a project which send email using CDOSYS. I am using vb.net with MSSQLServer 2000. The email is send out by calling stored procedure. The most challeging part the attachment which contains image need to shown as inline message in the message body. In short,my main concern is how to embed an image to show as inline message in an email? Below is the stored procedure that i am created and is still not working? I am hoping someone ou there can give me a solution.

CREATE PROCEDURE sp_cdosysmail

--specify the input parameters that insert values to stored procedure
@from varchar(100) ,
@to varchar(100) ,
@cc varchar(500),
@bcc varchar(500),
@subject varchar(200),
@body varchar(500) ,
@attachments varchar(1000),
@smtpserver varchar(25) = "aprskuldmn00006"

--body of the stored procedure
as
declare @imsg int
declare @result int
declare @bodytype int

--create an instance of the CDOSYS object
exec @result = sp_oacreate 'CDO.message', @imsg out

--set the value to the property
exec @result = sp_oasetproperty @imsg, 'configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").value', '2'
exec @result = sp_oasetproperty @imsg, 'configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").value', @smtpserver
exec @result = sp_oamethod @imsg, 'configuration.fields.update', null

--set email properties
exec @result = sp_oasetproperty @imsg, 'from', @from
exec @result = sp_oasetproperty @imsg, 'to', @to
exec @result = sp_oasetproperty @imsg, 'cc', @cc
exec @result = sp_oasetproperty @imsg, 'bcc', @bcc
exec @result = sp_oasetproperty @imsg, 'subject', @subject

EXEC @result= sp_OASetProperty @imsg, 'TextBody', @Body
--if you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.

DECLARE @strBodyHTML VARCHAR(8000)
SET @strBodyHTML = @Body
set @strBodyHTML=@strBodyHTML+'<HTML><HEAD>'
set @strBodyHTML=@strBodyHTML+'</HEAD>'
set @strBodyHTML=@strBodyHTML+'
set @strBodyHTML=@strBodyHTML+'<IMG SRC="@attachments">'
set @strBodyHTML=@strBodyHTML+'
set @strBodyHTML=@strBodyHTML+'</HTML>'
exec @result = sp_oasetproperty @imsg, 'HTMLBody', @strBodyHTML

--add attachment
if @attachments is not null
begin
declare
@charpos int,
@attachment varchar(1000),
@attachmentlist varchar(1000)

set @attachmentlist = @attachments
set @charpos = charindex(';', @attachmentlist, 1)

while @charpos > 0
begin
set @attachment = substring(@attachmentlist, 1, @charpos - 1)

if @attachment <> ''
begin
--@attachsend = 'insert into @attachmentlist values (@attachment)'
exec @result = sp_oamethod @imsg, 'addattachment', null, @attachment
end
set @attachmentlist = right(@attachmentlist, len(@attachmentlist) - @charpos)
set @charpos = charindex(';', @attachmentlist, 1)
end
--set @attachsend = (select attachment from @attachmentlist)
end

declare @type int
exec @bodytype = sp_oacreate 'CDO.BodyPart', @type out
set @type= @imsg
exec @bodytype= sp_oasetproperty @type,'fields("urn:schemas:httpmail:content-disposition-type").value','inline',@attachment
exec @bodytype= sp_oasetproperty @type,'fields ("urn:schemas:httpmail::content-type").value','multipart/mixed'

declare @contenttype varchar
exec @bodytype=sp_oagetproperty @type, 'ContentMediaType', @contenttype out
if @contenttype = 'cdoMultipartMixed'
begin
exec @bodytype = sp_oamethod @type, 'GetDecodedContentStream'
end

EXEC @bodytype = sp_OAMethod @type, 'Fields.Update'
EXEC @bodytype= sp_oamethod @type, 'send',null
GO

gnassar
Starting Member

1 Post

Posted - 2008-03-24 : 08:19:49
I am having the same issue. Did you ever find a solution?
Go to Top of Page
   

- Advertisement -