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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to generate an email from code

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Need to generate and send email from code
This code seems to take care of the profile in a multi user environment:

Set objNameSpace = objApp.GetNamespace("MAPI")
strTemp = objNameSpace.CurrentUser.Name
Call objNameSpace.Logon(strTemp, , False, False)

But how do I stop the warning box about someone is trying to send email from your system. Some of the other office products do things like DisplayAlerts=False, Warnings=Off, etc. Is there an equivalent in Outlook?

Thanks!


Have a great day!

j2consulting@yahoo.com
 
No, I think the whole point of that warning message is to stop malicious code from sending emails without your knowledge. If the coder could disable it easily, that would defeat the object.

Even if your code is digitally signed you still can't get around it, which I think is silly.

If I'm wrong somebody please enlighten me, because I'd like to do the same thing as SBendBuckeye!

N.
 
you can get around the outlook security prompt, you need to generate the email in a different format, the code below sends an email to a distribution list with an attachment and does not generate the security prompt.

Sub Mailer()
Sheets("BB Email Data").Select
pathname = [b11].value
dname = [b14].value
Dim objol As New outlook.Application
Dim objmail As MailItem
Set objol = New outlook.Application
Set objmail = objol.createitem(olmailitem)
With objmail
.To = "goodman,linda"
.cc = "tucker, Martin"
.Subject = "Daily Eshare Report for " & dname
.Body = "Please find attached the daily Eshare report" & _
vbCrLf & "If you have any queries can you please let me know" & vbCrLf
.NoAging = True
.Attachments.Add pathname
.display
End With
Set objmail = Nothing
Set objol = Nothing
SendKeys "%{s}", True

End Sub

i save the file(pathname) to the system and then attach I tried the way in the 1st post and got the security prompt, so I use this way now and it doesnt generate security prompt, I use this on a WIN NT outloook 2000 system at work, and also use on Windows XP, machine with Office XP, at home and it doesnt bring up the security prompt on either.

hope it helps.

Thanks Rob.[yoda]
 
LOL, our firewall blocks that thread because it thinks it has a virus. I'll try out robcarr's code though, ta.

N.
 
The key is NOT using the NameSpace. But if you have multiple profiles defined for the local workstation, then if you don't use NameSpace you may a select profile dialog if Outlook is setup to prompt for it.

Hopefully, some of the things in the thread above will work and this ugly issue goes away.


Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top