AutoPlay Media Studio ile Konu, Mesaj ve Dosya Ekli E-Posta Gönderme

guclusat

Tanınmış Üye
Süper Moderatör
Send Email with Subject, Body and Attachment
To send an e-mail with various fields filled in, use the File.OpenEmail action. The following can be filled in:
To, Cc, Bcc, Subject, Body.

  1. To send an email with the following properties:

    To: user@yourdomain.com
    Cc: user2@yourdomain.com
    Bcc: user3@yourdomain.com
    Subject: Your subject here
    Body: Whatever you want as your email body here

    Use the following action:
Kod:
File.OpenEmail("user@yourdomain.com?CC=user2@yourdomain.com&BCC=user3@yourdomain.com&Subject=Your subject here&Body=Whatever you want as your email body here", SW_SHOWNORMAL);

Note: To send an email with an attachment, you would have to Uuencode the file, and include it in the body of the email message. This is an advanced implementation of the File.OpenEmail action. Indigo Rose can not assist you with implementation details. Be aware that not all email clients will recognize all options.
 
AutoPlay Media Studio (AMS) projelerinde güncel sürümler (özellikle modern Windows API'leri, Lua altyapısı ve gelişmiş e-posta entegrasyonları) için File.OpenEmail yerine HTTP.SendMAIL veya COM nesneleri (CDO.Message / Outlook Application) kullanmak çok daha kararlı ve gelişmiş sonuçlar verir. File.OpenEmail yöntemi (mailto protokolü) gövde uzunluğu sınırlarına takılır ve ek (attachment) desteği konusunda yetersizdir.

Aşağıda modern sürümlere ve ihtiyaçlarınıza göre uyarlanmış alternatif kod çözümleri bulunmaktadır:

Yöntem 1: Harici E-Posta İstemcisi Yerine Doğrudan SMTP ile Gönderim (​

Kullanıcının varsayılan e-posta istemcisine bağımlı kalmadan, arka planda doğrudan SMTP sunucusu üzerinden Konu, Gövde ve Dosya Eki (Attachment) ile e-posta göndermek için aşağıdaki Lua kodunu kullanabilirsiniz:

Kod:
-- SMTP Sunucu Ayarları
local smtp_server = "smtp.yourdomain.com";
local port = 587; -- veya 465 (SSL)
local username = "user@yourdomain.com";
local password = "your_password";

local sender = "user@yourdomain.com";
local recipient = "hedef@domain.com";
local subject = "Güncel AMS E-Posta Testi";
local body = "Bu e-posta AutoPlay Media Studio'nun güncel sürümü ile gönderilmiştir.";
local attachment_path = "C:\\AutoPlay\\Files\\Rapor.pdf";

-- HTTP.SendMAIL fonksiyonu ile gönderim
local result = HTTP.SendMAIL(smtp_server, port, username, password, sender, recipient, subject, body, attachment_path);

if (result == 0) then
    Dialog.Message("Başarılı", "E-posta başarıyla gönderildi!");
else
    Dialog.Message("Hata", "E-posta gönderilemedi. Hata kodu: " .. tostring(result));
end

Yöntem 2: Windows CDO (Collaboration Data Objects) ile Ekli E-Posta Gönderimi​

Eğer SMTP şifrelerini kod içinde açıkça tutmak istemiyor ve kullanıcının sistemindeki varsayılan altyapıyı (veya SMTP sunucusunu) kullanarak ekli dosya göndermek istiyorsanız, Windows'un yerleşik CDO kütüphanesini Lua içerisinden çağırabilirsiniz:
Kod:
local recipient = "user@yourdomain.com";
local cc = "user2@yourdomain.com";
local subject = "Gelişmiş E-Posta Başlığı";
local body = "Bu mesaj gövdesidir.";
local attachment = "C:\\Dosyalar\\Belge.pdf";

-- CDO Mail Nesnesi Oluşturma
local cdoMessage = Luacom.CreateObject("CDO.Message");

if cdoMessage then
    cdoMessage.To = recipient;
    cdoMessage.CC = cc;
    cdoMessage.Subject = subject;
    cdoMessage.TextBody = body;
    
    -- Dosya eki ekleme
    if Office and File.DoesExist(attachment) then
        cdoMessage:AddAttachment(attachment);
    end

    -- SMTP Konfigürasyonu (Opsiyonel: Kendi SMTP sunucunuzu buraya tanımlayabilirsiniz)
    -- cdoMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
    -- cdoMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.yourdomain.com";
    -- cdoMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465;
    -- cdoMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1;
    -- cdoMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user@yourdomain.com";
    -- cdoMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "sifre";
    -- cdoMessage.Configuration.Fields:Update();

    cdoMessage:Send();
    Dialog.Message("Bilgi", "E-posta gönderim işlemi tamamlandı.");
else
    Dialog.Message("Hata", "CDO nesnesi oluşturulamadı.");
end

Özet ve Tavsiye​

  • Eski File.OpenEmail yöntemi (mailto protokolü) işletim sistemi sınırlarına takıldığı için dosya eklemeyi doğrudan desteklemez.
  • Yeni sürümlerde dosya eki (attachment) ve tam yetkili alan yönetimi (To, Cc, Bcc, Subject, Body) için Yöntem 1 (HTTP.SendMAIL) veya harici e-posta entegrasyonları en sağlıklı çözümdür.
 
Geri
Yukarı