?
Solved

Sending email thru Office 365

Posted on 2014-03-24
12
Medium Priority
?
1,288 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

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

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

840 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