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

sending an email

Status
Not open for further replies.

ton9

Programmer
Joined
Apr 17, 2001
Messages
5
Location
US
I am still trying to work on a program that reads a text file and then sends out that text as an email. right now I am just trying to set it up so I can send one email, then I will make a loop to send multiple emails. I just want to get it functional. My problem is that I keep getting an error message when I set up my mail object. Here is my code. Can someone help me figure out why I keep getting an error on this line.


Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, strMessage, JMail, strFrom, strTo, strSubject

strFrom= "myName@hotmail.com"
strTo="myName@hotmail.com"
strSubject="April Newsletter"

Set JMail = CreateObject("JMail.SMTPMail")

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\newsletter.txt", ForReading, False)
Do While f.AtEndOfStream <> True
strMessage = f.ReadAll
Loop
f.Close
Set f = Nothing
Set fso = Nothing

JMail.ServerAddress = &quot;mail.mydomain.com&quot;

' This is me....
JMail.Sender = strFrom
JMail.Subject = strSubject

' Get the recipients mailbox from a form (note the lack of a equal sign).
'JMail.AddRecipientex EMail, FirstName&&quot; &quot;&LastName
JMail.AddRecipient strTo

' The body property is both read and write.
' If you want to append text to the body you can
' use JMail.Body = JMail.Body & &quot;Hello world!&quot;
' or you can use JMail.AppendText &quot;Hello World!&quot;
' which in many cases is easier to use.
JMail.Body = strMessage

JMail.AppendText vbNewLine

' 1 - highest priority (Urgent)
' 3 - normal
' 5 - lowest

JMail.Priority = 3

' Send it...
JMail.Execute
Set Jmail = nothing







 
and maybe ASPmail (free!) from Persits Software ( is an alternative. br
Gerard
(-:

Better a known bug then a new release.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top