-
-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm sorry for the Noobish question below. Thanks a lot for the module and we had communicated on the emailimo module issues section and you had helped me out earlier as well.
Previously I had a working script with Emailimo module only. Now that emailimo is part of PSWriteHTML, I am having an issue with having the htmlFile saved with the below script.
Due to some reason, the htmlFile is not getting updated with below script mainly the
Email -FilePath $htmlFile -WhatIf
function RUN-emailimo_forWeeklyProgressReport {
Install-Module -Name PSWriteHTML -Force -Scope CurrentUser
Import-Module PSWriteHTML -Force
Import-Module Emailimo -Force
# $script:test = Email -Supress $false { #
Email -FilePath $htmlFile -WhatIf { #
EmailHeader {
EmailFrom -Address 'myAddress@gmail.com'
EmailTo -Addresses 'toAddress@company.com'
EmailServer -Server 'smtp.office365.com' -UserName 'myAddress@company.com' -Password 'myPassword' -SSL
EmailOptions -DeliveryNotifications Never -Priority Normal
EmailSubject -Subject $email_Subject
}
EmailBody -FontFamily 'Calibri' -Size 15 {
EmailText -Text "All, $currentTime" # , $UserNotify, "," -Color None, Blue, None -Verbose -LineBreak
EmailText -LineBreak
EmailText -Text "Please see below the progress on deliverables for the project. Detailed document status is attached."
EmailText -LineBreak
EmailText -Text 'A. Activities done during current week' -TextDecoration underline -FontWeight bold
EmailText -LineBreak
EmailTable -Table $new_activitiesDoneDuringCurrentWeek_DataTable -HideFooter # -DisableInfo -DisablePaging -DisableProcessing
EmailText -LineBreak
EmailText -Text 'B. Forecast Activities for the next week' -TextDecoration underline -FontWeight bold
EmailText -LineBreak
EmailTable -Table $new_forecastActivitiesForNextWeek_DataTable -HideFooter # -DisableInfo -DisablePaging -DisableProcessing
EmailText -LineBreak
EmailText -Text 'C. Progress Summary' -TextDecoration underline -FontWeight bold
EmailText -LineBreak
EmailTable -Table $new_cseProgress_dataTable -HideFooter # -DisableInfo -DisablePaging -DisableProcessing
EmailText -LineBreak
EmailText -Text 'D. Man-hour summary' -TextDecoration underline -FontWeight bold
EmailText -LineBreak
EmailTable -Table $new_manHourSummary_dataTable -HideFooter # -DisableInfo -DisablePaging -DisableProcessing
EmailText -LineBreak
EmailText -Text 'E. Remarks & Concerns ' -TextDecoration underline -FontWeight bold
EmailList -FontSize 15 {
EmailListItem -Text 'Discussions on modular frame re-use ongoing.'
EmailListItem -Text "Current Productivity is $([math]::Round($productivity,2))"
}
EmailText -LineBreak
EmailTextBox {
'Thanks & Regards'
'Name'
}
}
}
Write-Log -Message "SENDING EMAIL with email_IMO" -Path "$WeeklyProgressReportsFolder\Script.log" -Level Info
Write-Log -Message "test.Status $($test.Status)" -Path "$WeeklyProgressReportsFolder\Script.log" -Level Info
Write-Log -Message "test.SentTo $($test.SentTo)" -Path "$WeeklyProgressReportsFolder\Script.log" -Level Info
Write-Log -Message "test.Error $($test.Error)" -Path "$WeeklyProgressReportsFolder\Script.log" -Level Info
}
RUN-emailimo_forWeeklyProgressReport
[string]$htmlFile_AsString = Get-Content $htmlFile
function compose-OutlookEmail {
$outlookFolderDrafts = 16
$outlookObject = New-Object -comObject Outlook.Application
$nameSpace = $outlookObject.GetNameSpace("MAPI")
# call the save method yo dave the email in the drafts folder
$mail = $outlookObject.CreateItem(0)
$null = $Mail.Recipients.Add("manager@company.com")
$null = $Mail.Recipients.Add("lead@company.com")
$Mail.Subject = $email_Subject
$Mail.HTMLBody = "$htmlFile_AsString"
$mail.Attachments.Add($Source);
$Mail.importance = 2
$Mail.save()
# get it back from drafts and update the body
# $drafts = $nameSpace.GetDefaultFolder($outlookFolderDrafts)
# $draft = $drafts.Items | where {$_.subject -eq $email_Subject}
# $draft.body += "`n foo bar"
# $draft.save()
}
compose-OutlookEmail
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working