Solved

sending mails using outlook object

Posted on 2003-11-27
3
535 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:RTKVSNL
3 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9831424
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
0
 

Author Comment

by:RTKVSNL
ID: 9831520
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.
0
 
LVL 7

Accepted Solution

by:
wsteegmans earned 125 total points
ID: 9831878
Take a look at these links:
- http://www.dimastr.com/redemption/
- http://www.outlookforum.com/t36290-s

Included, some code that creates a Auto Reply for every new message in the Inbox ...
This example uses Outlook Redemption

Sub RedemptionMail()

Dim oOutlook As Outlook.Application
Dim oFldr As Outlook.MAPIFolder
Dim oMsg, oReply As Redemption.SafeMailItem
Dim mSender As Redemption.AddressEntry
Dim mSendQue As Redemption.MAPIUtils
Dim oMessage As Object
Dim oNs As Outlook.NameSpace
Dim mSubject, mFrom, mBody As String

Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI")
Set oFldr = oNs.PickFolder
Set oMsg = CreateObject("Redemption.SafeMailItem")
Set oReply = CreateObject("Redemption.SafeMailItem")
Set mSendQue = CreateObject("Redemption.MAPIUtils")

oMsg.AuthKey = "*******"
oReply.AuthKey = "*******"
mSendQue.AuthKey = "*******"

For Each oMessage In oFldr.Items
    oMsg.Item = oMessage
    oReply.Item = oMessage.Reply ' •¤• Create reply to original message •¤•
    oReply.Body = "Testing Auto Reply"
    oReply.Send
    mSubject = oMsg 'Get e-mail subject
    mFrom = oMsg.SenderName 'Get e-mail SendersName
    Set mSender = oMsg.Sender
    mFromAdd = mSender.Address
    mBody = oMsg.Body 'Get e-mail message body
Next oMessage

mSendQue.DeliverNow

Set oOutlook = Nothing
Set oNs = Nothing
Set oFldr = Nothing
Set oMsg = Nothing
Set oReply = Nothing
Set mSender = Nothing
Set mSendQue = Nothing

End Sub
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now