Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic
1 | 2 
lchiu7

5356 posts

Uber Geek

Trusted

  #2350817 9-Nov-2019 17:05
Send private message

Well I solved it with this script

 

 

 

$EmailFrom = "from@outlook.com"
$EmailTo = "to@gmail.com"
$EmailSubject = "Testing with attachments"  

 

$SMTPServer = "smtp.office365.com"
$SMTPAuthUsername = "authuser@outlook.com"
$SMTPAuthPassword = "password"

 

$emailattachment = "<fully qualified path and name>"

 

function send_email {
    $mailmessage = New-Object System.Net.Mail.MailMessage 
    $mailmessage.From = ($emailfrom) 
    $mailmessage.To.Add($emailto)
    $mailmessage.Subject = $emailsubject
    $mailmessage.Body = $emailbody
    $attachment = New-Object Net.Mail.Attachment($emailattachment)
    $attachment = New-Object Net.Mail.Attachment($emailattachment, "text/plain")
     $mailmessage.Attachments.Add($attachment)

 

 

 

    #$mailmessage.IsBodyHTML = $true
    $SMTP = New-Object Net.Mail.SmtpClient($SmtpServer, 587)  
    $SMTP.EnableSsl = $true
    $SMTP.Credentials = New-Object System.Net.NetworkCredential($SMTPAuthUsername , $SMTPAuthPassword) 
    $SMTP.Send($mailmessage)
    $attachment.dispose()
}

 

send_email

 

I did try using Send-MailMessage but it wasn't clear how to send the SMTP server credentials. The -credentials option seems to want to use the local server credentials

 

 

 

Thanks for all the suggestions

 

 





Staying in Wellington. Check out my AirBnB in the Wellington CBD.  https://www.airbnb.co.nz/rooms/32019730  Mention GZ to get a 10% discount

 

System One: Popcorn Hour A200,  PS3 SuperSlim, NPVR and Plex Server running on Gigabyte Brix (Windows 10 Pro), Sony BDP-S390 BD player, Pioneer AVR, Raspberry Pi running Kodi and Plex, Panasonic 60" 3D plasma, Google Chromecast

System Two: Popcorn Hour A200 ,  Oppo BDP-80 BluRay Player with hardware mode to be region free, Vivitek HD1080P 1080P DLP projector with 100" screen, Denon AVRS730H 7.2 Channel Dolby Atmos/DTS-X AV Receiver, Samsung 4K player, Google Chromecast, Odroid C2 running Kodi and Plex

 

 


fearandloathing
259 posts

Ultimate Geek

Lifetime subscriber

  #2351418 11-Nov-2019 09:27
Send private message

lchiu7:

 

 

 

I did try using Send-MailMessage but it wasn't clear how to send the SMTP server credentials. The -credentials option seems to want to use the local server credentials

 

 

 

 

You can use

 

$user = "user@example.com"
$password = "notmypassword"
$SecPassword = ConvertTo-SecureString $password -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ($user, $SecPassword)

 

#Example

 

Connect-EXOPSSession -UserPrincipalName $user -Credential $Cred


 
 
 
 


TwoSeven
1464 posts

Uber Geek


  #2351508 11-Nov-2019 11:28
Send private message

Ok, I’ve got to ask.

 

The OP mentioned a small office setup.

 

So I am wondering why OneDrive and not something like Azure Storage.





Software Engineer
   (the practice of real science, engineering and management)


SirHumphreyAppleby
1415 posts

Uber Geek


  #2351511 11-Nov-2019 11:41
Send private message

TwoSeven:

 

So I am wondering why OneDrive and not something like Azure Storage.

 

 

Possibly using the storage provided with an Office 365 subscription.


lchiu7

5356 posts

Uber Geek

Trusted

  #2351541 11-Nov-2019 12:31
Send private message

Right on the money. There is a local NAS which synchronises automatically to The office365 OneDrive account. But their accounting software requires that the database have daily and monthly backup so they have to be on two different directories on the SAN. I don't know any way of doing that automatically so it's done via nightly and monthly BAT jobs and I want to see the result.




Staying in Wellington. Check out my AirBnB in the Wellington CBD.  https://www.airbnb.co.nz/rooms/32019730  Mention GZ to get a 10% discount

 

System One: Popcorn Hour A200,  PS3 SuperSlim, NPVR and Plex Server running on Gigabyte Brix (Windows 10 Pro), Sony BDP-S390 BD player, Pioneer AVR, Raspberry Pi running Kodi and Plex, Panasonic 60" 3D plasma, Google Chromecast

System Two: Popcorn Hour A200 ,  Oppo BDP-80 BluRay Player with hardware mode to be region free, Vivitek HD1080P 1080P DLP projector with 100" screen, Denon AVRS730H 7.2 Channel Dolby Atmos/DTS-X AV Receiver, Samsung 4K player, Google Chromecast, Odroid C2 running Kodi and Plex

 

 


1 | 2 
Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic





News »

Huawei introduces new features to Petal Search, Maps and Docs
Posted 26-Oct-2020 18:05


Nanoleaf enhances lighting line with launch of Triangles and Mini Triangles
Posted 17-Oct-2020 20:18


Synology unveils DS16211+
Posted 17-Oct-2020 20:12


Ingram Micro introduces FootfallCam to New Zealand channel
Posted 17-Oct-2020 20:06


Dropbox adopts Virtual First working policy
Posted 17-Oct-2020 19:47


OPPO announces Reno4 Series 5G line-up in NZ
Posted 16-Oct-2020 08:52


Microsoft Highway to a Hundred expands to Asia Pacific
Posted 14-Oct-2020 09:34


Spark turns on 5G in Auckland
Posted 14-Oct-2020 09:29


AMD Launches AMD Ryzen 5000 Series Desktop Processors
Posted 9-Oct-2020 10:13


Teletrac Navman launches integrated multi-camera solution for transport and logistics industry
Posted 8-Oct-2020 10:57


Farmside hits 10,000 RBI customers
Posted 7-Oct-2020 15:32


NordVPN starts deploying colocated servers
Posted 7-Oct-2020 09:00


Google introduces Nest Wifi routers in New Zealand
Posted 7-Oct-2020 05:00


Orcon to bundle Google Nest Wifi router with new accounts
Posted 7-Oct-2020 05:00


Epay and Centrapay partner to create digital gift cards
Posted 2-Oct-2020 17:34









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.