Send web mail from Excel (VBA)??

M

MaxS

Hi,

is it possible to do the following in VBA:

I run a lenthy simulation on another computer and would like the
program to send me an emai when it is finished.

If I do this using MS Outlook i get a security warning which asks to
press "OK". So not much automation after all.
Can I send an email automatically using a web email account like gmail
or hotmail?


Thanks a lot?
 
M

MaxS

Hi Ron,

your site helped and I could send the message via my gmail account.
However when I run the same code from work i get the following message:

"ActiveX component can't create object" on the line of code
"Set iConf = CreateObject(" CDO.Configuration")"

I have Win XP and Office 2002 at home and in the office. So the systems
are the same.

Any ideas why this can happen?

Here goes my code:

Sub Mail_Small_Text_CDO()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject(" CDO.Configuration")

' iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("
http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

..Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
") = 1

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.gmail.com "

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 465
.Item("
http://schemas.microsoft.com/cdo/configuration/sendusername") =
"(e-mail address removed)"
.Item("
http://schemas.microsoft.com/cdo/configuration/sendpassword") = "my
pass"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl ") =
True
.Update
End With

strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.From = """MasS"" < (e-mail address removed)>"
.Subject = "Important message"
.TextBody = strbody
.Send
End With



Set iMsg = Nothing
Set iConf = Nothing
End Sub
 
N

NickHK

Max,
At a guess, it looks like you have a extra leading space in "
CDO.Configuration".

NickHK
 
M

MaxS

Thanks Nick!
I indeed missed that. Now however I get another error "The SendUsing
configuration value is invalid" but this probably has something to do
with company security settings, I guess..
 
R

Ron de Bruin

Hi Max

If you not have a account in Outlook Express you must use the commented code lines in the examples on my site.
Read the text on my site
 
M

MaxS

well, I did use those lines - they are just ugly formatted in the
message above. And I know that this code did work without Outlook at my
home - I got ony gmail account and not mail clinent.

Thank you.
 
M

MaxS

I think it is the firewall. When I ping smtp server all packages are
lost. However the code works fine on another network.

Thanks for the help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top