outlook (create new message)

albertkhor

Well-known member
Joined
Jan 12, 2006
Messages
150
Programming Experience
Beginner
how to create new message and attact file to outlook or outlook express? like some website when you click on send mail link, outlook will create new message without lunch the outlook.

can someone teach me?
 
Here's a little routine to send an e-mail with outlook. If you dig around a bit i'm sure you'll be able to find a way to attach files.

VB.NET:
Dim app As Microsoft.Office.Interop.Outlook.Application
Dim appNameSpace As Microsoft.Office.Interop.Outlook._NameSpace
Dim memo As Microsoft.Office.Interop.Outlook.MailItem
Dim outbox As Microsoft.Office.Interop.Outlook.MAPIFolder
Try
app = New Microsoft.Office.Interop.Outlook.Application
appNameSpace = app.GetNamespace("MAPI")
appNameSpace.Logon(Nothing, Nothing, False, False)
memo = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
memo.To = "Anthony.Patton@Ingenix.com" 
memo.Subject = "TechRepublic.com Test"
memo.Body = "Hello there"
memo.Send()
Catch ex As COMException
messagebox.show(ex.meaasge)
End Try
 
vis781 said:
Here's a little routine to send an e-mail with outlook. If you dig around a bit i'm sure you'll be able to find a way to attach files.

VB.NET:
Dim app As Microsoft.Office.Interop.Outlook.Application
Dim appNameSpace As Microsoft.Office.Interop.Outlook._NameSpace
Dim memo As Microsoft.Office.Interop.Outlook.MailItem
Dim outbox As Microsoft.Office.Interop.Outlook.MAPIFolder
Try
app = New Microsoft.Office.Interop.Outlook.Application
appNameSpace = app.GetNamespace("MAPI")
appNameSpace.Logon(Nothing, Nothing, False, False)
memo = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
memo.To = "Anthony.Patton@Ingenix.com" 
memo.Subject = "TechRepublic.com Test"
memo.Body = "Hello there"
memo.Send()
Catch ex As COMException
messagebox.show(ex.meaasge)
End Try

thx for reply! But i cannot Imports Microsoft.Office.Interop did i need to add reference or how?
 
i have download the Outlook.dll from internet and at in the reference. I work fine but this is not what i want. Sorry that maybe i broken english make you misunderstand what i want.

i do not want to create my own email form, what i want is run the outlook system and use it create new message function. The ideal is i open the outlook system and click on "Create new message button", so the new message form will appear.

sorry that i make you confuse.
 
most websites, when you click on a link that sends them an email, are using a hyperlink in the form:

mailto:email@address.com

This is bringing up what the user's internet browser recognizes as the user's default email client to send the new message (usually outlook or outlook express) -- it's a functionality of browsers, not necessarily a programming language.

That said, I believe there is a way to do what you want, but it may be somewhat involved -- especially considering that being able to automatically send out an email with an attachment is a fairly big security risk (it's the #1 source of viruses)
 
There is a thread somewhere on creating your own simple mail server and app, try a search ;-)
 
Rayanth said:
most websites, when you click on a link that sends them an email, are using a hyperlink in the form:

mailto:email@address.com

This is bringing up what the user's internet browser recognizes as the user's default email client to send the new message (usually outlook or outlook express) -- it's a functionality of browsers, not necessarily a programming language.

That said, I believe there is a way to do what you want, but it may be somewhat involved -- especially considering that being able to automatically send out an email with an attachment is a fairly big security risk (it's the #1 source of viruses)

that mean i cannot found this function (bringing up default email client) in programming language? this function is only available for browsers?
 
Pace said:
There is a thread somewhere on creating your own simple mail server and app, try a search ;-)

i hv successfully create my own mail server and app. But i do not want to use my own. i want to call outlook or outlook express. Now i already know how to call ms outlook (add ms outlook dll to my system) but not in outlook express. This is because i cannot add outlook express dll in my system, because outlook express is not com-base.

so i want to know why when i click on the hyperlink (e.g.mailto:email@address.com) in some websites, system will open the user's default email and create new message.
 
It means that it is a feature of most browsers. I'm not saying you can't do it on your own, but that it may be much more complicated than you expect.

I suspect the Outlook DLL must have something in it to use... I don't have access to the DLL to look at its various hooks though.
 
Back
Top