Solved

Send Email using VBScript from the server without SMTP service

Posted on 2011-04-27
6
847 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
ID: 35476978
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
ID: 35477171
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
ID: 35477327
Just to confirm, you're using it like this:

Call SendEmailGMail("Test", "test", "johndoe@gmail.com", "mypassword", "janedoe@gmail.com")
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 8

Author Comment

by:newbie27
ID: 35481809
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
ID: 35481829
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
ID: 35482437
Hi,
Make sure you are using correct username and password
Cheers
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Easy CSR creation in Exchange 2007,2010 and 2013
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In this video we show how to create a Distribution Group 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 Recipients >>…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 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