Check if CDO e-mail is supported on Volusion Windows server - email

I am trying to use CDO to send e-mail through a Volusion Windows server. The ASP script I've written works fine on a GoDaddy Windows server so I know the script is correct but it doesn't work through Volusion. In that script, I had used GoDaddy's relay-hosting.secureserver.net SMTP server to send the e-mail and it worked great on the GoDaddy server but not on Volusion.
I've tried several SMTP servers. Volusion provides documentation on their mail servers here:
https://support.volusion.com/article/connecting-my-volusion-e-mail-account
I've tried both the SMTP servers with SSL and without in the script (and have also tried all the different ports).
I'm wondering if the ability to send e-mails with CDO is not supported on Volusion servers? Is there a way to check if a server supports CDO without having access to the cPanel, WHM or any core files? With Volusion, they only give you access to part of the FTP.
Thanks for your help!
EDIT
Here is the code I used that worked:
<%
sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"
' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
' Server port (typically 25)
objConfig.Fields.Update
' Create and send the mail
Set myMail=CreateObject("CDO.Message")
' Use the config object created above
Set myMail.Configuration=objConfig
myMail.From="test#test.com"
myMail.To="test#test.com"
myMail.Subject = "Test Subject"
myMail.HTMLBody = "Test"
myMail.Send
Set myMail = Nothing
response.write "Success!!"
%>
I've obviously updated those e-mail address when I run the code.
EDIT
To answer a question in the comments my server version is:
Microsoft-IIS/6.0

To answer your initial question, how to check CDO is supported.
Here is a quick example of checking for the Object Required error (or any error for that matter while instantiating the CDO COM object.
Dim cdo, is_cdosupported
On Error Resume Next
Err.Clear
Set cdo = Server.CreateObject("CDO.Configuration")
is_cdosupported = (Err.Number <> 0)
On Error Goto 0
If is_cdosupported Then
Call Response.Write("CDO is supported")
Else
Call Response.Write("CDO not supported")
End If
Digging around on Google
After commenting a few times decided to dig into Volusion (must admit not one I've come across and after a quick search in Google found this link.
Quote from The VSMTP Key
A special ASP class is provided for use with Volusion's built-in send-mail component, VSMTP.
You can use this class to create your own send mail solutions for your store using ASP. Note that the information being provided in this article is intended for advanced users. This solution provides an alternate to sending email via Volusion's standard POP-based or webmail-based solutions.
If you're using Volusion's standard email hosting resources (POP, IMAP, or Webmail), you will not be required to update any functions within your store or my.volusion.com account.
To use the VSMTP component with your Volusion store, you will need to download Volusion's VSMTP ASP class.
Judging by the Object Required ASP component error you get when trying to instantiate the CDO components I would say that CDO is not supported by Volusion servers.
There is a simple example shown using the VSMTP ASP class
<%
Dim mailer
Set mailer = new vsmtp
mailer.VsmtpKey = "65539C7A-525C-4CB7-B36B-BFBBDD332DD6"
mailer.EmailSubject = "Test Subject"
mailer.EmailFrom = "test#testdomain.com"
mailer.EmailTo = "test#testdomain.com"
mailer.TextBody = "Hello World!"
mailer.HTMLBody = "Hello World"
mailer.AddAttachment Server.MapPath("/v/test1.txt")
mailer.AddAttachment "/v/test2.txt"
mailer.Send()
%>
Your best bet is to adapt your existing script to use this VSMTP bespoke class that is support by Volusion.
Looking at the VSMTP ASP class, it looks like it's a simple wrapper to POST to an ASP endpoint (vsmtp.asp).
<%
Class vsmtp
Public VsmtpKey
Public EmailSubject
Public EmailFrom
Public EmailTo
Public TextBody
Public HTMLBody
Private Attachment
Private AttachmentFolder
Public Sub AddAttachment(ByRef FilePath)
If AttachmentFolder = "" Then
AttachmentFolder = Server.MapPath("/v")
End If
If StrComp(Left(FilePath,Len(AttachmentFolder)),AttachmentFolder,vbTextCompare) = 0 Then
FilePath = Replace(Mid(FilePath,Len(AttachmentFolder)-1),"\","/")
End If
If StrComp(Left(FilePath,3),"/v/",vbTextCompare) <> 0 Or InStr(FilePath,",") > 0 Then
Err.Raise 512, "vsmtp.AddAttachment", "Invalid Attachment Path"
End If
If IsEmpty(Attachment) Then
Attachment = FilePath
Else
Attachment = Attachment & "," & FilePath
End If
End Sub
Public Sub Send()
Dim HTTPRequest
Set HTTPRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
HTTPRequest.Open "POST", "http://" & Request.ServerVariables("LOCAL_ADDR") & "/vsmtp.asp", False
HTTPRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HTTPRequest.SetRequestHeader "Host", Request.ServerVariables("SERVER_NAME")
HTTPRequest.Send _
"VsmtpKey=" & Server.URLEncode(VsmtpKey) &_
"&Subject=" & Server.URLEncode(EmailSubject) &_
"&FromEmailAddress=" & Server.URLEncode(EmailFrom) &_
"&ToEmailAddress=" & Server.URLEncode(EmailTo) &_
"&Body_HTML=" & Server.URLEncode(HTMLBody) &_
"&Body_TextOnly=" & Server.URLEncode(TextBody) &_
"&Attachment_CSV=" & Server.URLEncode(Attachment)
If HTTPRequest.ResponseText <> "True" Then
Set HTTPRequest = Nothing
Err.Raise 8, "vsmtp.Send", "Unable to send email. Check logs for details."
End If
Set HTTPRequest = Nothing
End Sub
End Class
%>

Short answer, you cannot. You will get an error message that states Access is denied. VSMTP is the only alternative to sending email directly from Volusion, however, you can only send from their SMTP servers and the options (e.g. Headers) are limited to what is provided.

Related

How to get VB6 to successfully pull xml data from a https site using REST API

I know vb6 is old, but I can quickly do what I need to do with the xml data in vb6 rather than learn a new lang. I just cannot get it to extract successfully from the required REST API sites.
In VB6, I've added the reference Microsoft XML 3 - 6 to try and see if it makes a difference, but it doesn't.
My code is really simple:
Dim sUrl As String
Dim xmlhttp As MSXML2.ServerXMLHTTP60
Set xmlhttp = New MSXML2.ServerXMLHTTP60
sUrl = "<url>"
xmlhttp.Open "GET", sUrl, False
xmlhttp.setRequestHeader "Content-Type", "application/xml"
xmlhttp.send ""
If xmlhttp.Status = 200 Then
Debug.Print xmlhttp.responseText
End If
Set xmlhttp = Nothing
I've tried changing the object ref to 'MSXML2.xmlhttp', 'XMLHTTP60', and 'MSXML2.ServerXMLHTTP', but still no difference.
Every time they either say System Error -2146697208 or access denied.
If I put the URL into a web browser and do view source then I see the xml text that I'm after.
I've even tried to run this all through a Classic ASP web page (I'm more familiar with this tech) and I still can't get this data down.
Does anybody know what the definitive code is to simply connect to a REST API site and bring it down as an xml text object??
Thanks
UPDATE 23-01-19
Hi All
Following on from Peter's comment, I've been trying to do this on my trusted Win XP SP3 machine and it wouldn't have it. I've just tried the below on a local ASP classic site on a Win 10 Pro machine and it works:
URL = "<the url>"
Set oXMLHTTP = Server.CreateObject("MSXML2.XMLHTTP.6.0")
oXMLHTTP.open "GET", URL, false
oXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHTTP.send
IF oXMLHTTP.Status = 200 THEN
Response.Write oXMLHTTP.ResponseText & "<BR>"
ELSE
Response.Write "Error"
END IF
If I run this exact routine on the classic ASP IIS on my Win XP machine it says invalid class string on the 'Set oXMLHTTP = Server.CreateObject("MSXML2.XMLHTTP.6.0")' line. If I change it from '6' to '5' it can see the object but then it doesn't work again.
I'm taking it that this all means that below v6 does not work with these https sites (TLS issue??) so I need to be using v6, but is this available for Win XP??
Thanks

Send an email from access via Lotus iNotes installed on intranet

I just need to be pointed in the right direction, on how
to send an email using VBA. I have Lotus as an email system which is embedded into our intranet system.
As a try, this code prepares an email and send it via Lotus (installed on pc) :
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim sender, recipient As String
'sender = Forms![LogIn]![TxtEmail]
If (Not IsNull(DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'"))) Then
recipient = DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'")
MsgBox "recipient *" & recipient & "*"
Else
MsgBox " recipient null"
End If
If Not (ns Is Nothing) Then
Call ns.InitializeUsingNotesUserName("CN=MyuserName/O=Cmpany", "password")
Set db = ns.GetDatabase("ServerName", "mail\MyuserName.nsf", False)
If (Not (db Is Nothing)) Then
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = recipient
doc.subject = "Email Subject"
Dim rt As NotesRichTextItem
Set rt = doc.CreateRichTextItem("Body")
rt.AppendText ("Body text")
doc.Send (False)
Set rt = Nothing
Set doc = Nothing
MsgBox "Message Sent."
Else
MsgBox "db Is Nothing"
End If
Set db = Nothing
Set ns = Nothing
Else
MsgBox "ns Is Nothing"
End If
My question here is how set this code to make the target Lotus the one on our intranet: my login is such "39398C#mycompany.com" and the application is accessed by "http://mail.mycompany.com/mail/username.nsf..."
Unfortunately this is not possible this way. This "embedded" Lotus Notes as you call it is a simple website. It is called "iNotes" and does not have any dlls installed on your client (unless you install the ActiveX control for IE, but that does not help anything with your problem).
For sending eMails via iNotes you need a complete new method and you need your Domino administrator to help you with it: You could either use a webservice to send your mail (this has to be enabled on the server) or you can use DIIOP (again: DIIOP- Task has to be loaded on server).
To at least compose an email, you could use the mailto: protocol, but you need to set iNotes to be your mailto- protocol- handler:
Open Internet Explorer browser and log into iNotes (http://mail.mycompany.com/mail/username.nsf). Please note that this option is not available at this time to Firefox browser users.
Click the "Preferences" button located in the top right corner.
Find "Default Mail Client" section on the "Basics" tab of the iNotes preferences.
Click the button "Make Default".
Using this approach you cannot send the mail directly but need the user to press "Send".
I am not sure what you mean by "I have Lotus as an email system which is embedded into our intranet system".
You need the Notes client installed locally to be able to use COM in your own code. Use the ID file (must be local in the Notes Data directory) for your corporate account amd point to the server on the network for your mailfile.
But you can't point your program to a iNotes instance on a web server, it has to be on a Domino server accessed with a Notes client.
What you could do is to create a new web application on the server, where you have an agent that will read HTTP POST data, create an email and send it out.
Then you simply make a HTTP post from your application.
Here are a couple of blog entries I wrote that might help you:
http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/
http://blog.texasswede.com/parse-url-in-domino-agent/
You should probably change your code to send mail via SMTP instead of using the Notes API objects. Microsoft provides an object model called CDO that I think will help you. See the answer to theis question for details. You will just need the hostname or IP address information to connect to a Domino server in your infrastructure that supports inbound SMTP.
Not sure about it, because that code is pretty old as we know use Outlook and I haven't use it in a long while, but that might be some insight :
I seem to remember that if you add doc.From = ns.CommonUserName, this will choose your session automatically!
And the full code :
Dim session As Object
Dim db As Object
Dim doc As Object
Dim attachme As Object
Dim EmbedObj As Object
Dim attachment() As String
Dim i As Integer
Set session = CreateObject("notes.notessession")
Set db = session.GetDatabase("", "")
Call db.OPENMAIL
Set doc = db.CreateDocument
With doc
.Form = "Memo"
.sendto = MailDestinataire
'.copyto = MailDestinataire2
.Subject = Sujet
.Body = CorpsMessage
.From = session.CommonUserName
.posteddate = Now
.SaveMessageOnSend = True
End With

Send mails from Notes - when it is not used for mail

Ok, in these times when some people move from Lotus Notes to Office 365 I have come across a certain requirement...
An older workflow application sends mail to users. This has worked fine for ages. But now we have a new type of users. These users are just using Notes for a couple of old legacy applications like the one in question.
The error we get is:
File does not exist
And the code that generates it is pretty simple:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim rtitem As NotesRichtextItem
Dim doc2 As NotesDocument
Set db = session.CurrentDatabase
Set doc2 = New NotesDocument(db)
doc2.Form = "Memo"
doc2.Subject = "Test mail " & now
Set rtitem = New NotesRichTextItem (doc2, "Body" )
Call rtitem.AppendText("A simple test....")
Call rtitem.addnewline(2)
Call rtitem.AppendText("Link to complaint ")
Call doc2.Replaceitemvalue("sendto", "john#dalsgaard-data.dk")
doc2.Send( False )
It fails when running the last line....
So, the question really is: How can I code around the this issue?
I know there is no mail file for the user - and I would really prefer not to have to create one for the new users.
Thanks in advance!
/John
Error will appear when user triggering the code doesn't have a mail file specified in person document/location. One option would be to change code to save the new mail directly to server mail.box (assuming server is configured to route mails) or just send the email directly through SMTP using java.
Ok, I have done some trial & error testing on this....
Conclusion so far is that it works in this situation:
In the LOCAL location document (in names.nsf on the computer) you specify:
Mail server - as a server the user can reach
Mail "On Server"
An existing mail file - it can be ANY existing file on the server, it doesn't have to be a mail database.
Actually, a non-conclusive test indicates the mail database even doesn't have to exist (but the user with the setup for testing had to leave - so I couldn't confirm this tonight...)
Edit:
Further testing indicates that this may not be a problem if the user is NOT roaming. I need some further verification that this is actually the reason why I got it working (for one thing you cannot remove the mail file name again once added)... But thought I would add it here.

Microsoft.Exchange.WebServices.Data.ServiceResponseException: When Sending Emails

I am using EWS Managed API to send email.
I am getting a Microsoft.Exchange.WebServices.Data.ServiceResponseException: EmailAddress or ItemId must be included in the request.
In the Soap return XML I see ErrorMissingInformationEmailAddress : This error occurs if the EmailAddress (NonEmptyStringType) element is missing.
Which email address is it talking about?
Using Exchange 2007 SP1.
Exchange credentials are correct and the to/from email addresses are valid emails.
Any ideas? Google has not helped.
Same code has worked for other Exchange Servers.
service.AutodiscoverUrl() does not work for this server.
using Microsoft.Exchange.WebServices.Data;
protected void SendEwsMail()
{
//Trust all certificates
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("user#domain.com", "password");
service.Url = new Uri("Url");
var email = new EmailMessage(service);
email.ToRecipients.Add("user#domain.com");
email.From = new EmailAddress("user#domain.com");
//email.ReplyTo.Add(recipient.FromAddress);
email.Sender = new EmailAddress("user#domain.com");
email.Subject = "test";
// Send the message and save a copy.
email.SendAndSaveCopy();
}
It turns out that for the mail Server (MS Exchange) in question I needed to use this method:
Writing an encrypted mail via Exchange Web Services
var item = new EmailMessage(service);
item.MimeContent = new MimeContent(Encoding.ASCII.HeaderName, content);
// Set recipient infos, etc.
item.Send();
It seems to be because of the encrypyed MIME attachment. Using the standard To, From, Subject properties of the Microsoft.Exchange.WebServices.Data.EmailMessage class does not work correctly.
Although it does work as expected when the mail server was SmarterMail.
SmarterMail 9.x is one of the only mail servers (including Microsoft Exchange) to support Exchange Web Services (EWS).
(from http://blogs.smartertools.com/tag/exchange-web-services/)
Anyone know why SmarterMail would behave differently to MS Exchange?

Use another framework than persits for Mails

I have to move some customer website from one (old) server to another (newer one). All sites are programmed in ASP. One customer sends Email (for his webshop) to his users using the persits framework, like
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.domain.com"
Mail.CharSet = "ISO..."
Mail.Username = "Admin#domain.com"
Mail.Password = "password"
Mail.From = shopmail
Mail.FromName = "Name"
Mail.AddAddress shopmail
Mail.Subject = "Order " & date
Mail.Body = msgBody
Mail.Send
This framework isn't installed on the new server and also there are no SMTP services installed.
How could I get it done that mails could be sent without the features mentioned above? Is there a way to reach a external STMP server with ASP?
Thanks in advance.
Best regards.
I'v found a solution, it's well documented here (for everyone who's interested in :) ).