Solved

Send Email using VBScript from the server without SMTP service

Posted on 2011-04-27
6
810 Views
Last Modified: 2012-05-11
Hello Experts
I used to have smtp server on the same host earlier but now we are using google aps to host our emails.
Now, all my old vbscripts to send emails are not working ...
Please can someone advise how can I make this script work?
Thanks

Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ghs.google.com"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update

objEmail.To = "admin@test.com"
objEmail.From = "admin@test.com"
objEmail.AddAttachment OutputDir & FileName & ".csv"
objEmail.Subject = "Daily Web Orders Report"
EmailBody = "Reports Test" & vbCrLf & vbCrLf
objEmail.TextBody = EmailBody
objEmail.Send
Set objEmail = Nothing

Open in new window

0
Comment
Question by:newbie27
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
spinzr0 earned 350 total points
Comment Utility
This should work
Sub SendEmailGMail(sSubject, sEmailText, sGmailEmailAddress, sGmailPassword, sTo)
    Set oEmail = CreateObject("CDO.Message")
    oEmail.From = sGmailEmailAddress
    oEmail.To = sTo

    oEmail.Subject = sSubject
    oEmail.HTMLbody = sEmailText

    sSchema = "http://schemas.microsoft.com/cdo/configuration/"
    oEmail.Configuration.Fields.Item(sSchema & "sendusing") = 2
    oEmail.Configuration.Fields.Item(sSchema & "smtpserver") = "smtp.gmail.com"
    oEmail.Configuration.Fields.Item(sSchema & "smtpserverport") = 465
    oEmail.Configuration.Fields.Item(sSchema & "smtpauthenticate") = 1
    oEmail.Configuration.Fields.Item(sSchema & "sendusername") = sGmailEmailAddress
    oEmail.Configuration.Fields.Item(sSchema & "sendpassword") = sGmailPassword
    oEmail.Configuration.Fields.Item(sSchema & "smtpusessl") = 1
    oEmail.Configuration.Fields.Item(sSchema & "smtpconnectiontimeout") = 60
    oEmail.Configuration.Fields.Update
    oEmail.Send

    Set oEmail = Nothing
End Sub

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
Comment Utility
Hi spinzr0
thanks for your input
I have tried but its not working .. the script seems to have ran.. but it did not send any email...
please can you advise
thanks
0
 
LVL 8

Expert Comment

by:spinzr0
Comment Utility
Just to confirm, you're using it like this:

Call SendEmailGMail("Test", "test", "johndoe@gmail.com", "mypassword", "janedoe@gmail.com")
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Author Comment

by:newbie27
Comment Utility
Hi,
Yes I am using exactly like above, but its not doing it... looks like its erroring but before i can read on the propmpt its disappearing...
please advise
thansk
0
 
LVL 8

Author Comment

by:newbie27
Comment Utility
errro message :
the message cannot be sent to the smtp server. the transport error was xxxxxx. the server response was not available
0
 
LVL 6

Assisted Solution

by:charlie324
charlie324 earned 150 total points
Comment Utility
Hi,
Make sure you are using correct username and password
Cheers
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now