how to create a email

  • Thread starter Thread starter Christoph Strobelt [Bt]
  • Start date Start date
C

Christoph Strobelt [Bt]

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
 
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("(e-mail address removed)"
olRecipientTo.Type = olT
Set olRecipientTo = .Recipients.Add("(e-mail address removed)"
olRecipientTo.Type = olT
Set olRecipientCC = .Recipients.Add("(e-mail address removed)"
olRecipientCC.Type = olCC 'olTo olCC or olBC
Set olRecipientBCC = .Recipients.Add("(e-mail address removed)"
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
 
hi,

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

chris
 
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
 
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 = "(e-mail address removed);[email protected]
.CC = "(e-mail address removed)
.BCC = "(e-mail address removed)
.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
 
Back
Top