Search The ForumSearch   RegisterRegister  LoginLogin

MailBee SMTP

 AfterLogic Forum : MailBee SMTP
Subject Topic: Import From Web Page Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
KC
Guest Group
Guest Group


Joined: 10 November 2003
Online Status: Online
Posts: 262
Posted: 25 September 2005 at 11:30pm | IP Logged Quote KC

I was trying to import a HTML page from some website using the ImportBodyText method but to no avail, the message body simply appeared blank. I have no such problem with HTML pages on local disk though.

Is there any other method that I can use to do this?
Back to Top View KC's Profile Search for other posts by KC
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 26 September 2005 at 9:44am | IP Logged Quote Alex

ImportBodyText method supports importing local HTML files only. To import a web page into the message body, you can use standard XMLHTTP object.

Code:

Dim objXMLHTTP, pageURL, objSMTP

pageURL = "http://www.afterlogic.com"

Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")

Set objSMTP = CreateObject("MailBee.SMTP")

objSMTP.LicenseKey = "Put your license key here"

objSMTP.ServerName = "mail.server.com"

' If your SMTP server requires authentication, please uncomment these lines
' objSMTP.UserName = "UserName"
' objSMTP.Password = "Password"
' objSMTP.AuthMethod = 2

objSMTP.FromAddr = "from@domain1.com"
objSMTP.ToAddr = "to@domain2.com"
objSMTP.Subject = "Web page"

objXMLHTTP.Open "GET", pageURL, False

objXMLHTTP.Send

If objXMLHTTP.Status = 200 Then
  objSMTP.BodyFormat = 1
  objSMTP.BodyText = objXMLHTTP.ResponseText

  If objSMTP.Send Then
    MsgBox "Sent successfully"
    objSMTP.Disconnect
  Else
    MsgBox "Error #" & objSMTP.ErrCode
  End If
Else
  MsgBox objXMLHTTP.Status & " " & objXMLHTTP.StatusText
End If

Set objXMLHTTP = Nothing
Set objSMTP = Nothing

Please note objXMLHTTP.Send method will throw an exception if the specified URL doesn't exist or network error occurs.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide