Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / June 2005

Tip: Looking for answers? Try searching our database.

how to create a email

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christoph Strobelt [Bt] - 27 Jun 2005 14:13 GMT
i don't find a way to create an email. can someone help?

in word its easy to create a document, but i can't handle it to create a
email in outlook.

i tried it this way

dim outapp as new outlook.application

set outapp = createobject("outlook.application")

how to go on? there is no command like addemail

outapp.addemail

bye chris
Sue Mosher [MVP-Outlook] - 27 Jun 2005 21:43 GMT
Take a look at the Application.CreateItem method.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

>i don't find a way to create an email. can someone help?
>
[quoted text clipped - 12 lines]
>
> bye chris
John Gregory - 28 Jun 2005 01:47 GMT
Chris
I think this example code answers your questions. You can run thi
from Ol or from XL
Joh

Sub Create_OL_Mail(
  Dim olApp As Outlook.Applicatio
  Dim olMailItm As Outlook.MailIte
  Dim olRecipientTo As Outlook.Recipien
  Dim olRecipientCC As Outlook.Recipien
  Dim olRecipientBCC As Outlook.Recipien
   
  ' Create new instance of OL or open current instance
  Set olApp = New Outlook.Applicatio
  ' Create new message
  Set olMailItm = olApp.CreateItem(olMailItem
  ' Add message recipient, then send or display
  With olMailIt
     Set olRecipientTo = .Recipients.Add("JohnDoe@isp.com"
     olRecipientTo.Type = olT
     Set olRecipientTo = .Recipients.Add("JakeDoe@isp.com"
     olRecipientTo.Type = olT
     Set olRecipientCC = .Recipients.Add("JaneDoe@isp.com"
     olRecipientCC.Type = olCC 'olTo olCC or olBC
     Set olRecipientBCC = .Recipients.Add("SuzyDoe@isp.com"
     olRecipientBCC.Type = olBC
     .Subject = "Msg created in VBA
     .Body = "Msg created by VBA.
    .Display ' Display or Sen
  End Wit
  Set olMailItm = Nothin
  'olApp.Qui
  'Set olApp = Nothin
End Su
Christoph Strobelt [Bt] - 28 Jun 2005 06:41 GMT
hi,

thanks for your fast answer to my question. it works great.
thanks a lot,

chris
Christoph Strobelt [Bt] - 28 Jun 2005 07:31 GMT
i still have a question. is there a way to avoid the automatic opening of
this security dialog box,
which asks whether to allow access to my saved email-adress-list?

bye
chris
John Gregory - 29 Jun 2005 01:47 GMT
Chris
It is "almost impossible" to not show the OL "SecurityBox", by desig
to curtail spam and viruses. (1) Programs can be "purchased" to d
that and some early versions of OL would not show it, until update
were installed. But the short answer is no. (2) The work aroun
below, tested in OL2K, does not access the OL name space objec
and/or does not access the email addresses stored in Outlook. But th
scope of what this VB code can do is also limited for the sam
reason

Sub Create_OL_Mail_NoSecurityBox(
  Dim olApp As Outlook.Applicatio
  Dim olMailItm As Outlook.MailIte
  Dim olRecipientTo As Strin
  Dim olRecipientCC As Strin
  Dim olRecipientBCC As Strin
  ' Create new instance of OL or open current OL
  Set olApp = New Outlook.Applicatio
  ' Create new OL mail item
  Set olMailItm = olApp.CreateItem(olMailItem
  ' Add message recipients, then send or display
  With olMailIt
     .To = "JohnDoe@isp.com;JohnSmith@isp.com
     .CC = "JaneDoe@isp.com
     .BCC = "SuzyDoe@isp.com
     .Subject = "Msg created in VBA
     .Body = "Msg created by VBA.
    .Display ' Display or Sen
  End Wit
  Set olMailItm = Nothin
  'olApp.Qui
  'Set olApp = Nothin
End Su
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.