send a mail from VBA / excel

R

rhXX

hi all,

how can i send a mail from excel using VBA.

that is, i have a program in excel (VBA) and at the end i obtain a
text file with the results.

i need to send a simple mail (TO:, SUBJECT: ) with this text info as
body of the mail.

i would like when i "click" my program, at the end it send this mail

tks in advance
 
R

rhXX

keith,

tks, nice!

i already tested and works ok writting the mail in the outlook outbox!

BUT, i have a problem, i am not used outlook, but mozilla firefox, so
i need to access to mozilla outbox, or connect directly to email
server (?????)

sorry i didn't explain complete in my first post :-(

any ideas?

tks in advance.
 
R

rhXX



keith, tks a lot!!!!!

that page shows how to use MS CDO

- i enabled its reference, and worked fine with the simple example

Sub Mail1()
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "(e-mail address removed)"
objMessage.To = "(e-mail address removed)"
objMessage.TextBody = "This is some sample message text."

'==This section provides the configuration information for the remote
SMTP server.
'==Normally you will only change the server name or IP.

objMessage.Configuration.Fields.item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
= "smtp.toto.com"

'Server port (typically 25)
objMessage.Configuration.Fields.item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

End Sub
 

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