?
Solved

Send Email using VBScript from the server without SMTP service

Posted on 2011-04-27
6
Medium Priority
?
951 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
spinzr0 earned 1400 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 600 total points
ID: 35482437
Hi,
Make sure you are using correct username and password
Cheers
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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 >>…
In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
Suggested Courses

800 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