Outlook Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob

    #1

    Outlook Problem

    I have been using "mapi" to send mail from my vb applications for
    some time. I am now working in vb.net. The problem I am having now is
    that I need the "from" address to be different than the default one
    for the user.

    I could not find a way to change the "from" address when sending a
    mail. Another way that would work would be to change to a different
    email account or change the default account to something different. I
    could find a way to do that either.

    I finally solve it by setting by a second profile and logging on as the
    alternate profile. This solution turned out to be unacceptable to the
    user. For one thing she had to be completely log out of her normal
    profile or it would work. Below is the code I use so you can see what
    I'm doing.

    Dim mobjOutlook As New Outlook.Applica tion

    Dim moItems As Outlook.Items

    Dim moCt As Outlook.Contact Item
    ' Dim oCt As Outlook.DistLis tItem

    Dim mobjmail As Outlook.MailIte m
    Dim mMyAttachments As Object

    Dim oNS As Outlook.NameSpa ce = mobjOutlook.Get Namespace("mapi ")
    oNS.Logon(mProf ilename, "", False, True) '
    mobjmail = mobjOutlook.Cre ateItem(0)


    ' Send the mail
    With mobjmail
    .Subject = pSubject
    .Body = pBody
    .To = pTo
    .CC = pcc
    .BCC = pBcc
    .Send()

    End With

Working...