Solved

Send Email using VBScript from the server without SMTP service

Posted on 2011-04-27
6
875 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 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

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.
Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In this video we show how to create an email address policy 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…

734 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