Why email part.body doesn't change?

R

rabarama

this code doesn't work... why?
how can i add that head to that body?

head is the html text i want to add to p (a tmail object)

def injecthead(head,p)
if p.multipart? then
p.parts.each do |pa|
injecthead(head,pa)
end
else
if p.content_type=="text/html" then
if p.body!=nil then
startbodytag=p.body.index("<body")
endbodytag=(p.body[startbodytag...p.body.length]).index(">")
if startbodytag!=nil then
p.body.insert(startbodytag+endbodytag+1,head)

#i'm sure this code is worked but p.body doesn't change.
#if i put
altbody=p.body.insert(startbodytag+endbodytag+1,head),
#altbody is the body i want, but if then i write
p.body=altbody, p.body becames nil

end
end
end

end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,167
Messages
2,570,913
Members
47,455
Latest member
Delilah Code

Latest Threads

Top