Link to home
Start Free TrialLog in
Avatar of RTKVSNL
RTKVSNL

asked on

sending mails using outlook object

i am developing an application to send mails using the outlook object. since i was getting a security alert everytime the mails were sent, i downloaded and used the Redemption.dll library and safe mail objects.

i have pasted the code below:

Set myItem = CreateObject("Redemption.SafeMailItem")
Set oitem = oOutlookApplication.CreateItem(olMailItem)
strToAddress = olInboxItems_ItemAdd(myITems(intcnt))
myItem.Item = oitem
myItem.Recipients.Add (strToAddress)
myItem.Recipients.ResolveAll
myItem.Subject = "test"
myItem.Body = "this is a test"

the problem with this code is that the mails are sent to the draft folder and not the outbox. i found out why this is happening. it is because there is no email address in "sent by". i am not able to assign a sent by email address using redemption. so what is the solution to this?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Try this see if this solve your problem:

Private Sub Command4_Click()
    Dim iOutlook As Outlook.Application
    Dim myApp As Outlook.MailItem
    Set iOutlook = New Outlook.Application
    Set myApp = iOutlook.CreateItem(olMailItem)
    temp = "username"
    txtMessage = "Hello World Again!"
    AttachFile = "C:\test\test.gif"
    myApp.To = "receiver@domain.com"
    myApp.Subject = "Hello World!"
    myApp.Attachments.Add AttachFile
    myApp.Body = "Hi " & temp & vbCrLf & vbCrLf & txtMessage
    myApp.Send
    Do While iOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox).Items.Count <> 0
        DoEvents
    Loop
    MsgBox "Successfully Sent", vbInformation, "Email Sent"
End Sub
Avatar of RTKVSNL
RTKVSNL

ASKER

this cannot solve my problem because outlook has a security patch that needs a response from the user every time a mail will be sent. that is why i am using the redemption object.
ASKER CERTIFIED SOLUTION
Avatar of wsteegmans
wsteegmans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial