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
Solved

Sending email thru Office 365

Posted on 2014-03-24
12
1,090 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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