Sie sind auf Seite 1von 2

public withevents myolitems as outlook.

items

public sub application_startup()

' reference the items in the inbox. because myolitems is declared


' "withevents" the itemadd event will fire below.
set myolitems = outlook.session.getdefaultfolder(olfolderinbox).items

end sub

private sub myolitems_itemadd(byval item as object)

on error goto endinghere

dim newmail as outlook.mailitem

dim senderemail as string

dim oldemailbody as string


dim newemailbody as string
dim newsubj as string

' check to make sure it is an outlook mail message, otherwise


' subsequent code will probably fail depending on what type
' of item it is.

if typename(item) = "mailitem" then

'get email address of email address


senderemail = cstr(item.senderemailaddress)

if instr(ucase(senderemail), "sapient") = 0 then

' get itemmail to forward the item just received


set newmail = item.forward

oldemailbody = cstr(item.htmlbody)
newsubj = cstr(item.subject)

newmail.subject = "autore: " + newsubj

newemailbody = "<div align='justify'><font family='verdana, arial'


color='blue'><h3>hello!<br /> &nbsp;&nbsp;this is my business e-mail id. kindly
send me non-business emails on <a
href='mailto:saxenamilan@gmail.com'>saxenamilan@gmail.com</a> instead of this
one</h3></font></div>"

newemailbody = newemailbody & "<font family='verdana, arial'


color='#999999'><div align='justify'><h3><br /><u>note:</u></h3></div><div
align='justify'><h4><br />&nbsp;&nbsp;&nbsp;this is an autogenerated e-mail, meant
to stop spam on office mail server. <br />&nbsp;&nbsp;&nbsp;i have received ur e-
mail and i'll get back to you soon.<br /> &nbsp;&nbsp;&nbsp;you don't need to
respond to this email. kindly ignore the e-mail, if i asked you to send me e-mails
to this e-mail id.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - milan saxena
(<a href='mailto:saxenamilan@gmail.com'>saxenamilan@gmail.com</a>)<br /><br /><br
/><br /><hr><br /></h4></font></div>"

newemailbody = newemailbody & oldemailbody

'msgbox newemailbody

' address the message


newmail.recipients.add senderemail

newmail.bodyformat = olformathtml
newmail.htmlbody = newemailbody

' send it

newmail.send

end if

end if

endinghere:

end sub

Das könnte Ihnen auch gefallen