Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook CC

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
0
0
US
I use a WSH program to generate and send an email. The code is as follows:

' Create email object
Set oolApp = CreateObject("Outlook.Application")
Set email = oolApp.CreateItem(0)
email.Recipients.Add("me@myemail.com")

' Create the body of the email
MailBody = &quot;<!DOCTYPE HTML PUBLIC &quot;&quot;-//W3C//DTD W3 HTML//EN&quot;&quot;>&quot;
MailBody = MailBody & &quot;<HTML>&quot; & vbcrlf
MailBody = MailBody & &quot;<HEAD><TITLE>No Invoices</TITLE></HEAD>&quot;
MailBody = MailBody & &quot;<BODY>&quot; & vbcrlf
MailBody = MailBody & &quot;<B>For Your Information</B>,<BR><BR>&quot;
MailBody = MailBody & &quot;No invoices were issued today.<BR><BR>&quot;
MailBody = MailBody & &quot;</BODY></HTML>&quot;

' Send the Email
email.Subject = &quot;No Invoices Issued&quot;
email.HTMLBody = MailBody
email.Send

In relation to adding recipients for the email, how do you add someone to the CC or Bcc list. Any help would be appreciated.

Mighty
 
Figured it out:

dim recipient
set recipient = email.Recipients.Add(&quot;me@myemail.com&quot;)
recipient.Type = 3


Mighty
 
Hi Mighty,

I came upon your post and this is exactly the same as I was trying to create. I tested your code and got this
messages:

&quot;A program is trying to access e-mail address stored in Outlook. Do you want to allow this?&quot;

When I clicked [YES], I got this

&quot;A program is trying to automatically send e-mail on you behalf. Do you want to allow this?&quot;

When I clicked [YES], nothing happenned, I tried to send it to my e-mail ad but I didn't receive it.

Is this an Outllok config issue?
 
Don't know too much about it - I never came across those errors. By the sound of it, I reckon it's some kind of permissions issue.

Are you doing this from a VBScript program or using ASP?

Mighty
 
I'm doing it from a VBScript Program (WSH).
 
Sorry EdRev, I don't think that I am going to be able to help you. My own situation is that I run scripts on my own client PC and when the scripts send an email they just use my own Outlook mail profile.

I never encountered any errors while trying to send emails. I am also running the scripts using my own NT user account and I am an administrator on our domain.

Mighty
 
I recieved it too, but I just updated my office to the latest service packs. Maybe Mighty does not have latest service packs or maybe a script issue, Glad to know that I get a warning, since so many virus going around.

Mike T
 
hi mighty, sorry for coming in this question since you have your answer, but I have a question about your code, how do you send an attachment instead using your code.
thanks
kv
 
Using the code that I specified above, to add an attachment you simply do the following:

email.attachments.Add(&quot;c:\myfile1.txt&quot;)
email.attachments.Add(&quot;c:\myfile2.txt&quot;)
email.attachments.Add(&quot;c:\myfile3.txt&quot;)

Hope that helps

Mighty
 
Does anyone know how to suppress these messages when I'm sending email from my own workstation? The script is part of a .bat file and I can't have these messages popping up.

&quot;A program is trying to access e-mail address stored in Outlook. Do you want to allow this?&quot;

&quot;A program is trying to automatically send e-mail on you behalf. Do you want to allow this?&quot;

Thanks
 
This is a security issue. See your options setting.

Hope This Help
PH.
 
PH,

What securiy issue should I be looking at? And if you don't mind, how do I set it?
 
Sorry if I'm talking rubbish but would the following work?

email.To = &quot;address1&quot;
Email.CC = &quot;Address2&quot;
email.BCC = &quot;Address3&quot;
 
Hi,

The message you got &quot;A program is trying to access e-mail address stored in Outlook. Do you want to allow this?&quot; is due to a security patch from Microsoft. You can find more info about it if you search for &quot;Object Model Guard&quot; in internet.


Peter
 
can i know what does the 0 stands for in Set email = oolApp.CreateItem(0) ??
 
Sentmemail
O is the intrinsic outlook item it sate which default form is required.
 
I am having the same problem with the message box when Outlook tries to email a document from within my EXE: &quot;A program is trying to automatically send e-mail on you behalf. Do you want to allow this?&quot;

However, I have never received the message: &quot;A program is trying to access e-mail address stored in Outlook. Do you want to allow this?&quot;

Does anyone know how I can get rid of the this message box:(&quot;A program is trying to automatically send e-mail on you behalf. Do you want to allow this?&quot;)??
 
To avoid this message, your exe should use Extended MAPI.
Do a google search for &quot;Object Model Guard&quot;.
The Redemption solution seems to be a good one.


Hope This Help
PH.
 
I am having this same problem and I have been researching it for a while. I have outlook 2002 and office 2002, Windows 2000 professional and utilize Access 97 heavily. This is the problem. Since the patch, I get the message as you stated. This is due to me running a Access databse script that generates email from outlook. Some days it generates 1 email and some hundreds...so you can see my frustration since I am getting this wonderful pop up box on each message.

Any help would be appreciated. I did look up the object model guard but was totally lost.
 
If you want to try a different tack take a look at this:

It's freeware and pretty darn good. I use the email stuff from it since it just uses smtp. Quick, easy, and darn near foolproof. At least I have yet to have any problems with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top