Solved

Sending email thru Office 365

Posted on 2014-03-24
12
1,025 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

746 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

12 Experts available now in Live!

Get 1:1 Help Now