Цитата:
Сообщение от djmix
Код:
::
:: Send email notifications from cli via Mail.ru
::
chcp 1251
set mailsender=mailsend.exe
set smtpsender=username@mail.ru
set smtpsenderfullname=User Name
set smtpserver=smtp.mail.ru
set smtpport=465
set smtpuser=username@mail.ru
set smtppwd="password"
set mailto=usernanme@yandex.ru
set subject="Тестовая тема"
set body="Тестовый текст"
set attach="C:\file.txt"
::
::
%mailsender% -smtp %smtpserver% -port %smtpport% -ssl -auth -user %smtpuser% -pass %smtppwd% -t %mailto% -f "%smtpsender%" -name "%smtpsenderfullname%" -cs 1251 +cc +bc -q -attach %attach% -sub %subject% -M %body%
::
pause
::
придётся по ходу батник формировать, но может кто ответит?
|
таким путём фигня получается, гораздо дольше и не нужная инфа)
полезно хотя бы, что могу разбирать письма)
нашёл вот такой код
https://www.add-in-express.com/creat...tlook-message/
помогите преобразовать на дельфи
Код:
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
...
void SetAccount_2007_2010(Outlook.MailItem mail, string accountName)
{
Outlook.NameSpace session = mail.Session;
Outlook.Accounts accounts = session.Accounts;
for (int i = 1; i < = accounts.Count; i++)
{
Outlook.Account account = accounts[i];
if (account.DisplayName.ToLower() == accountName.ToLower())
{
mail.SendUsingAccount = account;
Marshal.ReleaseComObject(account);
break;
}
Marshal.ReleaseComObject(account);
}
Marshal.ReleaseComObject(accounts);
Marshal.ReleaseComObject(session);
}
Imports System.Runtime.InteropServices
Imports Outlook = Microsoft.Office.Interop.Outlook
...
Sub SetAccount_2007_2010(ByRef mail As Outlook.MailItem, _
ByVal accountName As String)
Dim session As Outlook.NameSpace = mail.Session
Dim accounts As Outlook.Accounts = session.Accounts
For i As Integer = 1 To accounts.Count
Dim account As Outlook.Account = accounts(i)
If account.DisplayName.ToLower() = accountName.ToLower() Then
mail.SendUsingAccount = account
Marshal.ReleaseComObject(account)
Exit For
End If
Marshal.ReleaseComObject(account)
Next i
Marshal.ReleaseComObject(accounts)
Marshal.ReleaseComObject(session)
End Sub
и вот пример на С шарпе
Код:
using System;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace OutlookAddIn1
{
class Sample
{
public static void SendEmailFromAccount(Outlook.Application application, string subject, string body, string to, string smtpAddress)
{
// Create a new MailItem and set the To, Subject, and Body properties.
Outlook.MailItem newMail = (Outlook.MailItem)application.CreateItem(Outlook.OlItemType.olMailItem);
newMail.To = to;
newMail.Subject = subject;
newMail.Body = body;
// Retrieve the account that has the specific SMTP address.
Outlook.Account account = GetAccountForEmailAddress(application, smtpAddress);
// Use this account to send the e-mail.
newMail.SendUsingAccount = account;
newMail.Send();
}
public static Outlook.Account GetAccountForEmailAddress(Outlook.Application application, string smtpAddress)
{
// Loop over the Accounts collection of the current Outlook session.
Outlook.Accounts accounts = application.Session.Accounts;
foreach (Outlook.Account account in accounts)
{
// When the e-mail address matches, return the account.
if (account.SmtpAddress == smtpAddress)
{
return account;
}
}
throw new System.Exception(string.Format("No Account with SmtpAddress: {0} exists!", smtpAddress));
}
}
}
ещё раз повторюсь, сейчас только осталось добиться - нажимая в программе на письмо, увидеть список всех учёток и выбрать необходимую от кого отправить.