Solved

Sending email thru Office 365

Posted on 2014-03-24
12
1,044 Views
Last Modified: 2014-04-07
Up to now we've been using Lotus Notes in the attched script. I have no idea at all what to do to have the same process going using Office 365.

I need serious help here

Thanks
Cheers


'option explicit
 
    Dim oSession        ' AS NotesSession
    Dim strServer
    Dim strUserName
    Dim strMailDbName
    Dim oCurrentMailDb  ' as NOTESDATABASE
    Dim oMailDoc        ' as NOTESDOCUMENT
    Dim ortItem         ' as NOTESRICHTEXTITEM
    Dim ortAttacment    ' as NOTESRICHTEXTITEM
    Dim oEmbedObject    ' as ????
    dim cstrAttachment
    dim emailaddress
    dim filename
    Dim blAttachment

    'christian_requin@goodyear.com

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    objStartFolder = "D:\phone bills\email\detail"
    Set objFolder = objFSO.GetFolder(objStartFolder)
    Set colFiles = objFolder.Files

    For Each objFile in colFiles
    cstrAttachment = objfile
    Dot = (InStr(objfile.name ,".pdf"))

    emailaddress   = left(objfile.name,dot - 1)
   
    'wscript.echo objfile & " " & emailaddress
   
    blAttachment = True
 
    Set oSession = CreateObject("Notes.NotesSession")
 
    strServer = oSession.GetEnvironmentString("MailServer",True)
   
    strUserName = oSession.UserName
 
    strMailDbName = Left(strUserName, 1) & Right(strUserName, (Len(strUserName) - InStr(1, strUserName, "")))&".nsf"
 
    set oCurrentMailDb = oSession.CurrentDatabase
 
    If oCurrentMailDb.IsOpen = True Then
        ' Already open for mail
    Else
        oCurrentMailDb.OPENMAIL
    End If
    Set oMailDoc = oCurrentMailDb.CREATEDOCUMENT
 
    OMailDoc.form = "Memo"  
 
    with oMailDoc
        .Principal = "CN=GDT IT Support/OU=GDT IT Support/O=GDYR"
        .SendTo  = ucase(emailaddress)
        .Subject = "Mobile Phone Bill"  
        .Body = "Please contact Joe Barcellona for all queries" & vbcrlf
    end with
 
'    set ortItem = oMaildoc.CREATERICHTEXTITEM("Body")
'    with ortItem

'    End With
 
    If blAttachment Then
        Set ortAttacment = oMailDoc.CREATERICHTEXTITEM("Attachment")
        Set oEmbedObject = ortAttacment.EMBEDOBJECT(1454, "", cstrAttachment, "Attachment")
    End If
   

    with oMailDoc
        .PostedDate = Now()
        .SAVEMESSAGEONSEND = "False"

        .send(False)
    end with
   
    next

    ' close objects
    set oMailDoc       = nothing
    set oCurrentMailDb = nothing
    set oSession       = nothing
0
Comment
Question by:Bianchi928
  • 6
  • 3
  • 3
12 Comments
 
LVL 10

Expert Comment

by:bigbigpig
ID: 39953479
See this article from Microsoft:
http://technet.microsoft.com/en-us/library/dn554323.aspx

Since I have several internal applications and scanners that require basic SMTP capability I set up a quick little virtual machine running Debian & Postfix.  You will not have to store any credentials using this method since your sending IP will be authenticated.  Using a relay also allows for you to use bogus email addresses that don't resolve to an actual mailbox.  So for example my printers use 'mfc@domain.com' but there is no such mailbox on Office 365.

If you think that's right for you then let me know if you need help setting that up.
0
 

Author Comment

by:Bianchi928
ID: 39954448
Nope, that's not right for me.

Regards
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39954537
You could keep one simple Domino server, just for mails...

And this article: http://support.microsoft.com/kb/161088 ?
0
 

Author Comment

by:Bianchi928
ID: 39955020
Thanks for your advice. Will this work since Outlook will be web base ? What i want is something do the same things as my attached script but in an Office 365 environment.  I'm a bit lost..
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39956628
If you'll be using the Outlook client, the code should be useable. If you have to use a browser to read your mails, it's a different story. So: Outlook, or no Outlook, that's the question.
0
 

Author Comment

by:Bianchi928
ID: 39957291
The recipients will have to use a browser to real their email.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 250 total points
ID: 39957763
It's not the recipients who are the problem, it's the sender who uses the VB application. The sender therefore needs some means to send a mail out. If there is no mail client application available, e.g. Outlook or Notes, the VB will have to send the mail all by itself, but always through some server, using SMTP.  Do you have that possibility in O365?

Read also this: http://www.emailarchitect.net/easendmail/ex/b/1.aspx
0
 

Author Comment

by:Bianchi928
ID: 39957779
I will check with the system administrator about the possibility/availability of using SMTP in O365 and get back to you
0
 
LVL 10

Assisted Solution

by:bigbigpig
bigbigpig earned 250 total points
ID: 39957789
SMTP is what I said and linked to in my first comment.  However, if you don't want to set a relay for it then you can send through smtp.office365.com if you set up your script to use authentication.
0
 

Author Comment

by:Bianchi928
ID: 39957844
Thanks for that
0
 
LVL 10

Expert Comment

by:bigbigpig
ID: 39958956
If you want to use that script then you will need to send through an SMTP relay.  I took another look at that article I had linked and you are required to use TLS when using smtp.office365.com and CDO does not support TLS.
0
 

Author Closing Comment

by:Bianchi928
ID: 39984708
Both answers were very helpful. Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to add field in my script 2 31
how to add fields in script 20 51
Using VB6 to write Excel Spreadsheets - 5 39
How can I save all open docs into a given folder 12 83
Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

911 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

20 Experts available now in Live!

Get 1:1 Help Now