发送延迟邮件传递并使用Powershell更改默认帐户

时间:2013-02-11 09:14:57

标签: email powershell outlook

我使用的是Outlook 2010和Powershell 2.0。

我想发送一条Outlook消息,并使用Powershell以编程方式延迟传递消息。

如何创建新的Outlook电子邮件并立即推迟发送?

2 个答案:

答案 0 :(得分:3)

如果您尝试这样做:

$ol = New-Object -comObject Outlook.Application  
$mail = $ol.CreateItem(0)  
$mail | Get-Member

您将获得邮件对象上可用的所有方法/属性的列表。

一个属性是DeferredDeliveryTime。您可以这样设置:

#Stay in the outbox until this date and time
$mail.DeferredDeliveryTime = "11/2/2013 10:50:00 AM"

或者:

#Wait 10 minutes before sending mail
$date = Get-Date
$date = $date.AddMinutes(10)
$mail.DeferredDeliveryTime = $date

答案 1 :(得分:0)

<强>解决方案:

$Mail.SendUsingAccount = $ol.Session.Accounts | where {$_.DisplayName -eq $FromMail}

参考文献:

Create Outlook email draft using PowerShell

http://office.microsoft.com/en-us/outlook-help/delay-or-schedule-sending-email-messages-HP010355051.aspx

<强>更新

更改默认帐户:

describe('Myctrl', function() {

   var $httpBackend, scope, createController, authRequestHandler;

   // Set up the module
   beforeEach(module('MyApp'));

   beforeEach(inject(function($injector) {

     // Set up the mock http service responses

     $httpBackend = $injector.get('$httpBackend');

     // backend definition common for all tests

     authRequestHandler = $httpBackend.when('GET', 'service.json')
                            .respond(true);

     // Get hold of a scope (i.e. the root scope)

     $rootScope = $injector.get('$rootScope');

     // The $controller service is used to create instances of controllers
     var $controller = $injector.get('$controller');


     createController = function() {

       return $controller('MyController', {'$scope' : scope});

     };

   })

);


   afterEach(function() {

     $httpBackend.verifyNoOutstandingExpectation();

     $httpBackend.verifyNoOutstandingRequest();


   });

   it('should fetch authentication token', function() {

     $httpBackend.expectGET('service.json');

     var controller = createController();

     expect(scope.names).toBe(true); 

     $httpBackend.flush();

   });


});

参考文献:
http://msmvps.com/blogs/richardsiddaway/archive/2011/08/08/outlook-sending-emails.aspx
Outlook automation - Change Sender Account

相关问题