Skicka Email
vet någon hur man kan skicka ett email i delphi utan att använda shellapi. vill inte att Outlook express ska startas, utan att det skickas iväg tyst och diskret. Helst skulle jag villa ha det så att: edit1.text = Email addresen, edit2.text = subject, memo1.lines = meddelande.
Ennu en annan sak, vet någon en komponent som gör att man kan skicka ett sms till en känykkä(mobiltelefon) via ett program i delphi
Tack på förhand!
Ruben
]////[;;;;:::::..
Svara
Sv: Skicka Email
hittade denna kod
procedure TForm1.Button1Click(Sender: TObject);
const
{ OlItemType constants }
olMailItem = 0;
olAppointmentItem = 1;
olContactItem = 2;
olTaskItem = 3;
olJournalItem = 4;
olNoteItem = 5;
olPostItem = 6;
{ OlAttachmentType constants }
olByValue = 1;
olByReference = 4;
olEmbeddedItem = 5;
olOLE = 6;
var
myOlApp, myItem, myRecipient, myAttachments: OleVariant;
begin
{ VBScript file to create a mail and add an attachment }
myOlApp := CreateOLEObject('Outlook.Application');
myItem := myOlApp.CreateItem(olMailItem);
myItem.Subject := 'This is the Subject';
myRecipient := myItem.Recipients.Add('recipientaddress@recipienthost.com');
myItem.Body := #13;
myItem.Body := myItem.Body + #13;
myItem.Body := myItem.Body + 'Hello,' + #13;
myItem.Body := myItem.Body + 'This code created this message and '+
' sent it and I didn't even have' + #13;
myItem.Body := myItem.Body + 'to click the send button!!!' + #13;
myItem.Body := myItem.Body + #13;
myItem.Body := myItem.Body + 'If you have any more problems, let me know' + #13;
myItem.Body := myItem.Body + 'rename to blah.vbs and run like this:' + #13;
myItem.Body := myItem.Body + 'wscript c:\blah.vbs' + #13;
myItem.Body := myItem.Body + #13;
myItem.Body := myItem.Body + 'MrBaseball34' + #13;
myItem.Body := myItem.Body + #13;
myItem.Body := myItem.Body + #13;
myItem.Body := myItem.Body + 'const' + #13;
myItem.Body := myItem.Body + ' // OlItemType constants' + #13;
myItem.Body := myItem.Body + ' olMailItem = 0;' + #13;
myItem.Body := myItem.Body + ' olAppointmentItem = 1;' + #13;
myItem.Body := myItem.Body + ' olContactItem = 2;' + #13;
myItem.Body := myItem.Body + ' olTaskItem = 3;' + #13;
myItem.Body := myItem.Body + ' olJournalItem = 4;' + #13;
myItem.Body := myItem.Body + ' olNoteItem = 5;' + #13;
myItem.Body := myItem.Body + ' olPostItem = 6;' + #13;
myItem.Body := myItem.Body + ' // OlAttachmentType constants' + #13;
myItem.Body := myItem.Body + ' olByValue = 1;' + #13;
myItem.Body := myItem.Body + ' olByReference = 4;' + #13;
myItem.Body := myItem.Body + ' olEmbeddedItem = 5;' + #13;
myItem.Body := myItem.Body + ' olOLE = 6;' + #13;
myItem.Body := myItem.Body + #13;
myItem.Body := myItem.Body + 'var'+ #13;
myItem.Body := myItem.Body + ' myOlApp, myItem, myRecipient, myAttachments: OleVariant;'
+ #13;
myItem.Body := myItem.Body + 'begin' + #13;
myItem.Body := myItem.Body + ' myOlApp := CreateObject(''Outlook.Application'')' + #13;
myItem.Body := myItem.Body + ' myItem := myOlApp.CreateItem(olMailItem)' + #13;
myItem.Body := myItem.Body + ' myItem.Subject := ''This is the Subject''' + #13;
myItem.Body := myItem.Body + ' myItem.Body := ''This is the body''' + #13;
myItem.Body := myItem.Body + ' myRecipient :=
myItem.Recipients.Add('recipientaddress@recipienthost.com')' + #13;
myItem.Body := myItem.Body + ' myAttachments := myItem.Attachments' + #13;
myItem.Body := myItem.Body + ' // Now let''s attach the files...' + #13;
myItem.Body := myItem.Body + ' myAttachments.Add ''C:\blah.txt'', olByValue, 1,
''Blah.txt Attachment''' + #13;
myItem.Body := myItem.Body + ' myItem.Send' + #13;
myItem.Body := myItem.Body + ' myOlApp := VarNull;' + #13;
myItem.Body := myItem.Body + ' myItem := VarNull;' + #13;
myItem.Body := myItem.Body + ' myRecipient := VarNull;' + #13;
myItem.Body := myItem.Body + ' myAttachments := VarNull;' + #13;
myItem.Body := myItem.Body + 'end;' + #13;
{ Now let's attach the files... }
myAttachments := myItem.Attachments;
myAttachments.Add('C:\blah.txt', olByValue, 1, 'Blah.txt Attachment');
myItem.Send;
myOlApp := VarNull;
myItem := VarNull;
myRecipient := VarNull;
myAttachments := VarNull;
end;
Svara