Click to See Complete Forum and Search --> : how to generate emails using outlook express


harshal_mankodi
August 28th, 2001, 11:25 PM
i want to genearte emails using outlook express object plz send me the codes and the libraries which i need to have along with the screen design as iam new to vb

Iouri
August 29th, 2001, 07:08 AM
add the Outlook Type library to the references of your project

Dim MyApp as Outlook.Application
Dim MyMailItem as Outlook.MailItem

set MyApp = new Outlook.Application
set MyMailItem = MyApp.CreateObject(olMailItem)
MyMailItem.Recipients.Add ("x@x.com") ' replace with a real address
'it can be '.To = "someone@microsoft.com"
MyMailItem.Subject = "Test" ' Subject field of the email
MyMailItem.Body = "This is just a Test!!!" ' main body of the email
'or for HTML report
'.HTMLBody = GetReport 'gets the report and puts into HTML
MyMailItem.CC = "y@y.com" ' replace with a real address
'.Importance = olImportanceNormal
MyMailItem.Send () ' send the message

'Close Outlook
Set MyApp = Nothing
Set MyMailItem = Nothing



'To send to recipients in thyour Address book
Recipients.Add "Joe Smith"), if "Joe Smith" is in your address book, & Outlook will find the right email address
for you.


Iouri Boutchkine
iouri@hotsheet.com

Raptors Fan
September 27th, 2001, 12:45 PM
I tried your code for Outlook 2000 and it failed at the line:

set MyMailItem = MyApp.CreateObject(olMailItem)



it works with the following line tho:

set MyMailItem = MyApp.CreateItem(olMailItem)