Solved

Sending email thru Office 365

Posted on 2014-03-24
12
1,155 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
[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
  • 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
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!

 

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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

707 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