[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Send Email using VBScript from the server without SMTP service

Posted on 2011-04-27
6
Medium Priority
?
993 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
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…
Suggested Courses

650 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